#include <MqttModel.h>
Classes | |
| class | MqttModelEntry |
| 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, MqttModelEntry > & | 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, MqttModelEntry > | modelMap |
| std::list< EventReceiver > | eventReceiverList |
| std::chrono::time_point< std::chrono::system_clock > | onlineSinceTimePoint |
| uint64_t | id = 0 |
Friends | |
| void | to_json (nlohmann::json &j, const MqttModel::MqttModelEntry &mqttModelEntry) |
Definition at line 74 of file MqttModel.h.
|
private |
Definition at line 200 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 210 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 270 of file MqttModel.cpp.
Referenced by mqtt::mqttbroker::lib::Mqtt::onConnect().
| void mqtt::mqttbroker::lib::MqttModel::disconnectClient | ( | const std::string & | clientId | ) |
Definition at line 276 of file MqttModel.cpp.
Referenced by mqtt::mqttbroker::lib::Mqtt::onDisconnected().
|
staticprivate |
Definition at line 377 of file MqttModel.cpp.
| const std::map< std::string, MqttModel::MqttModelEntry > & mqtt::mqttbroker::lib::MqttModel::getClients | ( | ) | const |
| Mqtt * mqtt::mqttbroker::lib::MqttModel::getMqtt | ( | const std::string & | clientId | ) | const |
Definition at line 306 of file MqttModel.cpp.
References mqtt::mqttbroker::lib::MqttModel::MqttModelEntry::getMqtt(), and modelMap.
|
static |
Definition at line 204 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 321 of file MqttModel.cpp.
References onlineSinceTimePoint.
Referenced by addEventReceiver().
| std::string mqtt::mqttbroker::lib::MqttModel::onlineSince | ( | ) | const |
Definition at line 317 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 292 of file MqttModel.cpp.
References id.
Referenced by mqtt::mqttbroker::lib::Mqtt::onPublish().
|
staticprivate |
Definition at line 325 of file MqttModel.cpp.
Referenced by sendEvent(), and sendJsonEvent().
|
private |
Definition at line 348 of file MqttModel.cpp.
References eventReceiverList, mqtt::mqttbroker::lib::MqttModel::EventReceiver::response, and sendEvent().
Referenced by sendJsonEvent().
|
private |
Definition at line 356 of file MqttModel.cpp.
References sendEvent().
|
staticprivate |
Definition at line 341 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 284 of file MqttModel.cpp.
References id.
Referenced by mqtt::mqttbroker::lib::Mqtt::onSubscribe().
|
staticprivate |
Definition at line 362 of file MqttModel.cpp.
| void mqtt::mqttbroker::lib::MqttModel::unsubscribeClient | ( | const std::string & | clientId, |
| const std::string & | topic ) |
Definition at line 288 of file MqttModel.cpp.
References id.
Referenced by mqtt::mqttbroker::lib::Mqtt::onUnsubscribe().
|
friend |
Definition at line 99 of file MqttModel.cpp.
References mqtt::mqttbroker::lib::MqttModel::MqttModelEntry::getMqtt(), mqtt::mqttbroker::lib::MqttModel::MqttModelEntry::onlineDuration(), and mqtt::mqttbroker::lib::MqttModel::MqttModelEntry::onlineSince().
|
private |
Definition at line 148 of file MqttModel.h.
Referenced by addEventReceiver(), and sendEvent().
|
private |
Definition at line 150 of file MqttModel.h.
Referenced by addEventReceiver(), connectClient(), disconnectClient(), publishMessage(), subscribeClient(), and unsubscribeClient().
|
private |
Definition at line 147 of file MqttModel.h.
Referenced by addEventReceiver(), connectClient(), disconnectClient(), getClients(), and getMqtt().
|
private |
Definition at line 149 of file MqttModel.h.
Referenced by MqttModel(), onlineDuration(), and onlineSince().