2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
42#ifndef MQTTBROKER_LIB_MQTTMODEL_H
43#define MQTTBROKER_LIB_MQTTMODEL_H
45namespace mqtt::mqttbroker::
lib {
59#ifndef DOXYGEN_SHOULD_SKIP_THIS
62#include <core/timer/Timer.h>
67#include <nlohmann/json_fwd.hpp>
72namespace mqtt::mqttbroker::
lib {
114 const std::string& lastEventId,
115 const std::shared_ptr<iot::
mqtt::server::
broker::Broker>& broker);
119 void subscribeClient(
const std::string& clientId,
const std::string& topic,
const uint8_t qos);
121 void publishMessage(
const std::string& topic,
const std::string& message, uint8_t qoS,
bool retain);
132 const std::string& data,
133 const std::string& event,
134 const std::string& id);
135 static void sendJsonEvent(
const std::shared_ptr<
express::Response>& response,
137 const std::string& event =
"",
138 const std::string& id =
"");
139 void sendEvent(
const std::string& data,
const std::string& event =
"",
const std::string& id =
"")
const;
140 void sendJsonEvent(
const nlohmann::json& json,
const std::string& event =
"",
const std::string& id =
"")
const;
142 static std::string timePointToString(
const std::chrono::time_point<std::chrono::system_clock>& timePoint);
144 durationToString(
const std::chrono::time_point<std::chrono::system_clock>& bevore,
145 const std::chrono::time_point<std::chrono::system_clock>& later = std::chrono::system_clock::now());
void publishMappings(const iot::mqtt::packets::Publish &publish)
MqttMapper(const nlohmann::json &mappingJson)
bool operator==(const EventReceiver &other)
std::weak_ptr< express::Response > response
EventReceiver(const std::shared_ptr< express::Response > &response)
core::timer::Timer heartbeatTimer
MqttModelEntry(MqttModelEntry &&) noexcept=default
MqttModelEntry(Mqtt *mqtt)
std::string onlineSince() const
std::string onlineDuration() const
void sendEvent(const std::string &data, const std::string &event="", const std::string &id="") const
void connectClient(Mqtt *mqtt)
std::chrono::time_point< std::chrono::system_clock > onlineSinceTimePoint
void publishMessage(const std::string &topic, const std::string &message, uint8_t qoS, bool retain)
void addEventReceiver(const std::shared_ptr< express::Response > &response, const std::string &lastEventId, const std::shared_ptr< iot::mqtt::server::broker::Broker > &broker)
static MqttModel & instance()
void unsubscribeClient(const std::string &clientId, const std::string &topic)
std::list< EventReceiver > eventReceiverList
std::map< std::string, MqttModelEntry > modelMap
Mqtt * getMqtt(const std::string &clientId) const
void subscribeClient(const std::string &clientId, const std::string &topic, const uint8_t qos)
void disconnectClient(const std::string &clientId)
static void sendEvent(const std::shared_ptr< express::Response > &response, const std::string &data, const std::string &event, const std::string &id)
const std::map< std::string, MqttModelEntry > & getClients() const
std::string onlineDuration() const
std::string onlineSince() const
void unsubscribe(const std::string &topic)
void publishMapping(const std::string &topic, const std::string &message, uint8_t qoS, bool retain) final
void onPublish(const iot::mqtt::packets::Publish &publish) final
void onConnect(const iot::mqtt::packets::Connect &connect) final
void subscribe(const std::string &topic, uint8_t qoS)
void onDisconnected() final
void onSubscribe(const iot::mqtt::packets::Subscribe &subscribe) final
void onUnsubscribe(const iot::mqtt::packets::Unsubscribe &unsubscribe) final
void to_json(nlohmann::json &j, const MqttModel::MqttModelEntry &mqttModelEntry)