2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
20#ifndef IOT_MQTT_CONTROLPACKET_H
21#define IOT_MQTT_CONTROLPACKET_H
23#ifndef DOXYGEN_SHOULD_SKIP_THIS
31#define MQTT_RESERVED_00 0x00
32#define MQTT_CONNECT 0x01
33#define MQTT_CONNACK 0x02
34#define MQTT_PUBLISH 0x03
35#define MQTT_PUBACK 0x04
36#define MQTT_PUBREC 0x05
37#define MQTT_PUBREL 0x06
38#define MQTT_PUBCOMP 0x07
39#define MQTT_SUBSCRIBE 0x08
40#define MQTT_SUBACK 0x09
41#define MQTT_UNSUBSCRIBE 0x0A
42#define MQTT_UNSUBACK 0x0B
43#define MQTT_PINGREQ 0x0C
44#define MQTT_PINGRESP 0x0D
45#define MQTT_DISCONNECT 0x0E
46#define MQTT_RESERVED_0F 0x0F
49#define MQTT_CONNECT_FLAGS 0x00
50#define MQTT_CONNACK_FLAGS 0x00
52#define MQTT_PUBACK_FLAGS 0x00
53#define MQTT_PUBREC_FLAGS 0x00
54#define MQTT_PUBREL_FLAGS 0x02
55#define MQTT_PUBCOMP_FLAGS 0x00
56#define MQTT_SUBSCRIBE_FLAGS 0x02
57#define MQTT_SUBACK_FLAGS 0x00
58#define MQTT_UNSUBSCRIBE_FLAGS 0x02
59#define MQTT_UNSUBACK_FLAGS 0x00
60#define MQTT_PINGREQ_FLAGS 0x00
61#define MQTT_PINGRESP_FLAGS 0x00
62#define MQTT_DISCONNECT_FLAGS 0x00
67 extern const std::vector<std::string> mqttPackageName;
71 ControlPacket(uint8_t type,
const std::string& name);
72 ControlPacket(
const ControlPacket&) =
default;
73 ControlPacket(ControlPacket&&) =
default;
75 virtual ~ControlPacket();
77 ControlPacket& operator=(
const ControlPacket&) =
default;
78 ControlPacket& operator=(ControlPacket&&) =
default;
80 virtual std::vector<
char> serializeVP()
const = 0;
81 std::vector<
char> serialize()
const;
83 const std::string& getName()
const;
84 uint8_t getType()
const;
85 uint8_t getFlags()
const;
#define SUBSCRIBTION_MAX_QOS
Session & operator=(const Session &)=default
std::set< uint16_t > publishPacketIdentifierSet
virtual nlohmann::json toJson() const
Session(const nlohmann::json &json)
bool isCleanSession() const
Session(const Session &)=default
virtual ~Session()=default
void fromJson(const nlohmann::json &json)
std::set< uint16_t > pubrelPacketIdentifierSet
SocketContextFactory()=default
virtual core::socket::stream::SocketContext * create(core::socket::stream::SocketConnection *socketConnection, std::shared_ptr< iot::mqtt::server::broker::Broker > broker)=0
core::socket::stream::SocketContext * create(core::socket::stream::SocketConnection *socketConnection) final
void restartSession(const std::string &clientId)
std::string sessionStoreFileName
uint8_t subscribe(const std::string &clientId, const std::string &topic, uint8_t qoS)
bool hasActiveSession(const std::string &clientId)
static std::shared_ptr< Broker > instance(uint8_t maxQoS)
bool isActiveSession(const std::string &clientId, const Mqtt *mqtt)
iot::mqtt::server::broker::RetainTree retainTree
void publish(const std::string &originClientId, const std::string &topic, const std::string &message, uint8_t qoS, bool retain)
bool hasSession(const std::string &clientId)
void appear(const std::string &clientId, const std::string &topic, uint8_t qoS)
void unsubscribe(const std::string &clientId, const std::string &topic)
Session * renewSession(const std::string &clientId, iot::mqtt::server::Mqtt *mqtt)
void deleteSession(const std::string &clientId)
void unsubscribe(const std::string &clientId)
bool hasRetainedSession(const std::string &clientId)
iot::mqtt::server::broker::SubscribtionTree subscribtionTree
Session * newSession(const std::string &clientId, iot::mqtt::server::Mqtt *mqtt)
void sendPublish(const std::string &clientId, Message &message, uint8_t qoS, bool retain)
void retainSession(const std::string &clientId)
void setMessage(const std::string &message)
const std::string & getOriginClientId() const
std::string originClientId
nlohmann::json toJson() const
const std::string & getTopic() const
void setTopic(const std::string &topic)
bool getOriginRetain() const
const std::string & getMessage() const
Message & operator=(const Message &)=default
Message(const Message &message)=default
Message(const std::string &originClientId, const std::string &topic, const std::string &message, uint8_t qoS, bool originRetain)
Message & fromJson(const nlohmann::json &json)
void retain(const Message &message, std::string topic)
void appear(const std::string &clientId, uint8_t clientQoS)
TopicLevel(iot::mqtt::server::broker::Broker *broker)
TopicLevel & fromJson(const nlohmann::json &json)
void appear(const std::string &clientId, std::string topic, uint8_t qoS)
nlohmann::json toJson() const
bool release(std::string topic)
void appear(const std::string &clientId, const std::string &topic, uint8_t qoS)
void retain(Message &&message)
void fromJson(const nlohmann::json &json)
RetainTree(iot::mqtt::server::broker::Broker *broker)
nlohmann::json toJson() const
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