#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 |
| std::uint64_t | nextEventReceiverId = 0 |
| uint64_t | id = 0 |
Definition at line 75 of file MqttModel.h.
|
private |
Definition at line 175 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 185 of file MqttModel.cpp.
References eventReceiverList, mqtt::mqttbroker::lib::MqttModel::EventReceiver::getId(), id, modelMap, nextEventReceiverId, onlineDuration(), and onlineSince().
Referenced by getRouter().
| void mqtt::mqttbroker::lib::MqttModel::connectClient | ( | Mqtt * | mqtt | ) |
Definition at line 249 of file MqttModel.cpp.
Referenced by mqtt::mqttbroker::lib::Mqtt::onConnect().
| void mqtt::mqttbroker::lib::MqttModel::disconnectClient | ( | const std::string & | clientId | ) |
Definition at line 255 of file MqttModel.cpp.
Referenced by mqtt::mqttbroker::lib::Mqtt::onDisconnected().
|
staticprivate |
Definition at line 356 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 285 of file MqttModel.cpp.
References modelMap.
|
static |
Definition at line 179 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 300 of file MqttModel.cpp.
References onlineSinceTimePoint.
Referenced by addEventReceiver().
| std::string mqtt::mqttbroker::lib::MqttModel::onlineSince | ( | ) | const |
Definition at line 296 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 271 of file MqttModel.cpp.
References id.
Referenced by mqtt::mqttbroker::lib::Mqtt::onPublish().
|
staticprivate |
Definition at line 304 of file MqttModel.cpp.
Referenced by sendEvent(), and sendJsonEvent().
|
private |
Definition at line 327 of file MqttModel.cpp.
References eventReceiverList, mqtt::mqttbroker::lib::MqttModel::EventReceiver::response, and sendEvent().
Referenced by sendJsonEvent().
|
private |
Definition at line 335 of file MqttModel.cpp.
References sendEvent().
|
staticprivate |
Definition at line 320 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 263 of file MqttModel.cpp.
References id.
Referenced by mqtt::mqttbroker::lib::Mqtt::onSubscribe().
|
staticprivate |
Definition at line 341 of file MqttModel.cpp.
| void mqtt::mqttbroker::lib::MqttModel::unsubscribeClient | ( | const std::string & | clientId, |
| const std::string & | topic ) |
Definition at line 267 of file MqttModel.cpp.
References id.
Referenced by mqtt::mqttbroker::lib::Mqtt::onUnsubscribe().
|
private |
Definition at line 134 of file MqttModel.h.
Referenced by addEventReceiver(), and sendEvent().
|
private |
Definition at line 137 of file MqttModel.h.
Referenced by addEventReceiver(), connectClient(), disconnectClient(), publishMessage(), subscribeClient(), and unsubscribeClient().
|
private |
Definition at line 133 of file MqttModel.h.
Referenced by addEventReceiver(), connectClient(), disconnectClient(), getClients(), and getMqtt().
|
private |
Definition at line 136 of file MqttModel.h.
Referenced by addEventReceiver().
|
private |
Definition at line 135 of file MqttModel.h.
Referenced by MqttModel(), onlineDuration(), and onlineSince().