#include <MqttModel.h>
Classes | |
| class | EventReceiver |
Public Member Functions | |
| void | addEventReceiver (const std::shared_ptr< express::Response > &response, const std::string &lastEventId, const std::shared_ptr< iot::mqtt::server::broker::Broker > &broker) |
| void | connectClient (Mqtt *mqtt) |
| void | disconnectClient (const std::string &clientId) |
| void | subscribeClient (const std::string &clientId, const std::string &topic, const uint8_t qos) |
| void | unsubscribeClient (const std::string &clientId, const std::string &topic) |
| void | publishMessage (const std::string &topic, const std::string &message, uint8_t qoS, bool retain) |
| const std::map< std::string, Mqtt * > & | getClients () const |
| Mqtt * | getMqtt (const std::string &clientId) const |
| std::string | onlineSince () const |
| std::string | onlineDuration () const |
Static Public Member Functions | |
| static MqttModel & | instance () |
Private Member Functions | |
| MqttModel () | |
| void | sendEvent (const std::string &data, const std::string &event="", const std::string &id="") const |
| void | sendJsonEvent (const nlohmann::json &json, const std::string &event="", const std::string &id="") const |
Static Private Member Functions | |
| static void | sendEvent (const std::shared_ptr< express::Response > &response, const std::string &data, const std::string &event, const std::string &id) |
| static void | sendJsonEvent (const std::shared_ptr< express::Response > &response, const nlohmann::json &json, const std::string &event="", const std::string &id="") |
| static std::string | timePointToString (const std::chrono::time_point< std::chrono::system_clock > &timePoint) |
| static std::string | durationToString (const std::chrono::time_point< std::chrono::system_clock > &bevore, const std::chrono::time_point< std::chrono::system_clock > &later=std::chrono::system_clock::now()) |
Private Attributes | |
| std::map< std::string, Mqtt * > | modelMap |
| std::list< EventReceiver > | eventReceiverList |
| std::chrono::time_point< std::chrono::system_clock > | onlineSinceTimePoint |
| uint64_t | id = 0 |
Definition at line 75 of file MqttModel.h.
|
private |
Definition at line 176 of file MqttModel.cpp.
References onlineSinceTimePoint.
| void mqtt::mqttbroker::lib::MqttModel::addEventReceiver | ( | const std::shared_ptr< express::Response > & | response, |
| const std::string & | lastEventId, | ||
| const std::shared_ptr< iot::mqtt::server::broker::Broker > & | broker ) |
Definition at line 186 of file MqttModel.cpp.
References eventReceiverList, id, modelMap, onlineDuration(), and onlineSince().
Referenced by getRouter().
| void mqtt::mqttbroker::lib::MqttModel::connectClient | ( | Mqtt * | mqtt | ) |
Definition at line 246 of file MqttModel.cpp.
Referenced by mqtt::mqttbroker::lib::Mqtt::onConnect().
| void mqtt::mqttbroker::lib::MqttModel::disconnectClient | ( | const std::string & | clientId | ) |
Definition at line 252 of file MqttModel.cpp.
Referenced by mqtt::mqttbroker::lib::Mqtt::onDisconnected().
|
staticprivate |
Definition at line 353 of file MqttModel.cpp.
| const std::map< std::string, Mqtt * > & mqtt::mqttbroker::lib::MqttModel::getClients | ( | ) | const |
| Mqtt * mqtt::mqttbroker::lib::MqttModel::getMqtt | ( | const std::string & | clientId | ) | const |
Definition at line 282 of file MqttModel.cpp.
References modelMap.
|
static |
Definition at line 180 of file MqttModel.cpp.
Referenced by getRouter(), mqtt::mqttbroker::lib::Mqtt::onConnect(), mqtt::mqttbroker::lib::Mqtt::onDisconnected(), mqtt::mqttbroker::lib::Mqtt::onPublish(), mqtt::mqttbroker::lib::Mqtt::onSubscribe(), and mqtt::mqttbroker::lib::Mqtt::onUnsubscribe().
| std::string mqtt::mqttbroker::lib::MqttModel::onlineDuration | ( | ) | const |
Definition at line 297 of file MqttModel.cpp.
References onlineSinceTimePoint.
Referenced by addEventReceiver().
| std::string mqtt::mqttbroker::lib::MqttModel::onlineSince | ( | ) | const |
Definition at line 293 of file MqttModel.cpp.
References onlineSinceTimePoint.
Referenced by addEventReceiver().
| void mqtt::mqttbroker::lib::MqttModel::publishMessage | ( | const std::string & | topic, |
| const std::string & | message, | ||
| uint8_t | qoS, | ||
| bool | retain ) |
Definition at line 268 of file MqttModel.cpp.
References id.
Referenced by mqtt::mqttbroker::lib::Mqtt::onPublish().
|
staticprivate |
Definition at line 301 of file MqttModel.cpp.
Referenced by sendEvent(), and sendJsonEvent().
|
private |
Definition at line 324 of file MqttModel.cpp.
References eventReceiverList, mqtt::mqttbroker::lib::MqttModel::EventReceiver::response, and sendEvent().
Referenced by sendJsonEvent().
|
private |
Definition at line 332 of file MqttModel.cpp.
References sendEvent().
|
staticprivate |
Definition at line 317 of file MqttModel.cpp.
References sendEvent().
| void mqtt::mqttbroker::lib::MqttModel::subscribeClient | ( | const std::string & | clientId, |
| const std::string & | topic, | ||
| const uint8_t | qos ) |
Definition at line 260 of file MqttModel.cpp.
References id.
Referenced by mqtt::mqttbroker::lib::Mqtt::onSubscribe().
|
staticprivate |
Definition at line 338 of file MqttModel.cpp.
| void mqtt::mqttbroker::lib::MqttModel::unsubscribeClient | ( | const std::string & | clientId, |
| const std::string & | topic ) |
Definition at line 264 of file MqttModel.cpp.
References id.
Referenced by mqtt::mqttbroker::lib::Mqtt::onUnsubscribe().
|
private |
Definition at line 131 of file MqttModel.h.
Referenced by addEventReceiver(), and sendEvent().
|
private |
Definition at line 133 of file MqttModel.h.
Referenced by addEventReceiver(), connectClient(), disconnectClient(), publishMessage(), subscribeClient(), and unsubscribeClient().
|
private |
Definition at line 130 of file MqttModel.h.
Referenced by addEventReceiver(), connectClient(), disconnectClient(), getClients(), and getMqtt().
|
private |
Definition at line 132 of file MqttModel.h.
Referenced by MqttModel(), onlineDuration(), and onlineSince().