MQTTSuite
Loading...
Searching...
No Matches
mqtt::mqttbroker::lib Namespace Reference

Classes

struct  subscribe
struct  unsubscribe
struct  retaine
struct  release
class  Mqtt
class  MqttModel

Functions

void to_json (nlohmann::json &j, const MqttModel::MqttModelEntry &mqttModelEntry)
void to_json (nlohmann::json &j, const subscribe &subscribe)
void to_json (nlohmann::json &j, const unsubscribe &unsubscribe)
void to_json (nlohmann::json &j, const retaine &retaine)
void to_json (nlohmann::json &j, const release &release)

Function Documentation

◆ to_json() [1/5]

void mqtt::mqttbroker::lib::to_json ( nlohmann::json & j,
const MqttModel::MqttModelEntry & mqttModelEntry )

Definition at line 99 of file MqttModel.cpp.

99 {
100 const Mqtt* mqtt = mqttModelEntry.getMqtt();
101 const core::socket::stream::SocketConnection* socketConnection = mqtt->getMqttContext()->getSocketConnection();
102
103 j = {{"clientId", mqtt->getClientId()},
104 {"since", mqttModelEntry.onlineSince()},
105 {"duration", mqttModelEntry.onlineDuration()},
106 {"connectionName", mqtt->getConnectionName()},
107 {"cleanSession", mqtt->getCleanSession()},
108 {"connectFlags", mqtt->getConnectFlags()},
109 {"username", mqtt->getUsername()},
110 {"usernameFlag", mqtt->getUsernameFlag()},
111 {"password", mqtt->getPassword()},
112 {"passwordFlag", mqtt->getPasswordFlag()},
113 {"keepAlive", mqtt->getKeepAlive()},
114 {"protocol", mqtt->getProtocol()},
115 {"protocolLevel", mqtt->getLevel()},
116 {"loopPrevention", !mqtt->getReflect()},
117 {"willMessage", mqtt->getWillMessage()},
118 {"willTopic", mqtt->getWillTopic()},
119 {"willQoS", mqtt->getWillQoS()},
120 {"willFlag", mqtt->getWillFlag()},
121 {"willRetain", mqtt->getWillRetain()},
122 {"localAddress", socketConnection->getLocalAddress().toString()},
123 {"remoteAddress", socketConnection->getRemoteAddress().toString()}};
124 }

◆ to_json() [2/5]

void mqtt::mqttbroker::lib::to_json ( nlohmann::json & j,
const release & release )

Definition at line 159 of file MqttModel.cpp.

159 {
160 j = {{"topic", release.topic}};
161 }
const std::string & topic

References mqtt::mqttbroker::lib::release::topic.

◆ to_json() [3/5]

void mqtt::mqttbroker::lib::to_json ( nlohmann::json & j,
const retaine & retaine )

Definition at line 151 of file MqttModel.cpp.

151 {
152 j = {{"topic", retaine.topic}, {"message", retaine.message}, {"qos", retaine.qoS}};
153 }
const std::string & topic
const std::string & message

References mqtt::mqttbroker::lib::retaine::message, mqtt::mqttbroker::lib::retaine::qoS, and mqtt::mqttbroker::lib::retaine::topic.

◆ to_json() [4/5]

void mqtt::mqttbroker::lib::to_json ( nlohmann::json & j,
const subscribe & subscribe )

◆ to_json() [5/5]

void mqtt::mqttbroker::lib::to_json ( nlohmann::json & j,
const unsubscribe & unsubscribe )

Definition at line 141 of file MqttModel.cpp.

141 {
142 j = {{"clientId", unsubscribe.clientId}, {"topic", unsubscribe.topic}};
143 }

References mqtt::mqttbroker::lib::unsubscribe::clientId, and mqtt::mqttbroker::lib::unsubscribe::topic.