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#include "iot/mqtt/server/broker/Session.h"
44#include "iot/mqtt/server/Mqtt.h"
46#ifndef DOXYGEN_SHOULD_SKIP_THIS
48#include "log/Logger.h"
53#include <nlohmann/json.hpp>
60namespace iot::mqtt::server::
broker {
67 LOG(INFO) <<
"MQTT Broker: TopicName: " << message
.getTopic();
69 LOG(DEBUG) <<
"MQTT Broker: QoS: " <<
static_cast<uint16_t>(std::min(qoS, message
.getQoS()));
81 LOG(INFO) <<
"MQTT Broker: Suppress reflection to origin to avoid message looping";
94 LOG(INFO) <<
"MQTT Broker: send queued messages ...";
98 LOG(INFO) <<
"MQTT Broker: ... done";
110 this->mqtt =
nullptr;
114 return mqtt !=
nullptr;
118 return this->mqtt == mqtt;
132 std::transform(json[
"message_queue"].begin(),
133 json[
"message_queue"].end(),
135 [](
const nlohmann::json& jsonMessage) {
static std::string toHexString(const std::string &data)
void sendPublish(const std::string &topic, const std::string &message, uint8_t qoS, bool retain)
virtual nlohmann::json toJson() const
void fromJson(const nlohmann::json &json)
std::string getClientId() const
const std::string & getOriginClientId() const
nlohmann::json toJson() const
const std::string & getTopic() const
bool getOriginRetain() const
const std::string & getMessage() const
Message & fromJson(const nlohmann::json &json)
void sendPublish(iot::mqtt::server::broker::Message &message, uint8_t qoS, bool retain)
std::deque< Message > messageQueue
nlohmann::json toJson() const final
Session(iot::mqtt::server::Mqtt *mqtt)
void fromJson(const nlohmann::json &json)
Session * renew(iot::mqtt::server::Mqtt *mqtt)
bool isOwnedBy(const iot::mqtt::server::Mqtt *mqtt) const