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-fast/SocketContext.h"
44#include "iot/mqtt-fast/ControlPacket.h"
45#include "iot/mqtt-fast/types/Binary.h"
47#ifndef DOXYGEN_SHOULD_SKIP_THIS
49#include "log/Logger.h"
65 LOG(DEBUG) <<
"MQTT (fast): Send CONNECT";
66 LOG(DEBUG) <<
"MQTT (fast): ============";
72 LOG(DEBUG) <<
"MQTT (fast): Send CONNACK";
73 LOG(DEBUG) <<
"MQTT (fast): ============";
79 LOG(DEBUG) <<
"MQTT (fast): Send PUBLISH";
80 LOG(DEBUG) <<
"MQTT (fast): ============";
86 LOG(DEBUG) <<
"MQTT (fast): Send PUBACK";
87 LOG(DEBUG) <<
"MQTT (fast): ===========";
93 LOG(DEBUG) <<
"MQTT (fast): Send PUBREC";
94 LOG(DEBUG) <<
"MQTT (fast): ===========";
100 LOG(DEBUG) <<
"MQTT (fast): Send PUBREL";
101 LOG(DEBUG) <<
"MQTT (fast): ===========";
107 LOG(DEBUG) <<
"MQTT (fast): Send PUBCOMP";
108 LOG(DEBUG) <<
"MQTT (fast): ============";
114 LOG(DEBUG) <<
"MQTT (fast): Send SUBSCRIBE";
115 LOG(DEBUG) <<
"MQTT (fast): ==============";
121 LOG(DEBUG) <<
"MQTT (fast): Send SUBACK";
122 LOG(DEBUG) <<
"MQTT (fast): ===========";
128 LOG(DEBUG) <<
"MQTT (fast): Send UNSUBSCRIBE";
129 LOG(DEBUG) <<
"MQTT (fast): ================";
135 LOG(DEBUG) <<
"MQTT (fast): Send UNSUBACK";
136 LOG(DEBUG) <<
"MQTT (fast): =============";
142 LOG(DEBUG) <<
"MQTT (fast): Send Pingreq";
143 LOG(DEBUG) <<
"MQTT (fast): ============";
149 LOG(DEBUG) <<
"MQTT (fast): Send Pingresp";
150 LOG(DEBUG) <<
"MQTT (fast): =============";
156 LOG(DEBUG) <<
"MQTT (fast): Send Disconnect";
157 LOG(DEBUG) <<
"MQTT (fast): ===============";
166 LOG(ERROR) <<
"MQTT (fast): SocketContext: Error during ControlPacket construction";
169 LOG(DEBUG) <<
"MQTT (fast): ======================================================";
244 std::stringstream ss;
248 for (
char const ch : data) {
249 if (i != 0 && i % 8 == 0 && i + 1 != data.size()) {
254 ss <<
"0x" << std::hex << std::setfill(
'0') << std::setw(2) <<
static_cast<uint16_t>(
static_cast<uint8_t>(ch))
258 LOG(DEBUG) << ss.str();
SocketContext(core::socket::stream::SocketConnection *socketConnection)
void sendToPeer(const char *chunk, std::size_t chunkLen) const final
ControlPacketFactory(core::socket::SocketContext *socketContext)
uint64_t getRemainingLength()
iot::mqtt_fast::types::Binary & getPacket()
std::vector< char > getPacket()
void sendPubrel(uint16_t packetIdentifier)
virtual void onPubrel(const iot::mqtt_fast::packets::Pubrel &pubrel)=0
SocketContext(core::socket::stream::SocketConnection *socketConnection)
void sendPubrec(uint16_t packetIdentifier)
virtual void onSuback(const iot::mqtt_fast::packets::Suback &suback)=0
virtual void onPingresp(const iot::mqtt_fast::packets::Pingresp &pingresp)=0
virtual void onPubcomp(const iot::mqtt_fast::packets::Pubcomp &pubcomp)=0
virtual void onDisconnect(const iot::mqtt_fast::packets::Disconnect &disconnect)=0
virtual void onConnect(const iot::mqtt_fast::packets::Connect &connect)=0
virtual void onPuback(const iot::mqtt_fast::packets::Puback &puback)=0
iot::mqtt_fast::ControlPacketFactory controlPacketFactory
void sendPubcomp(uint16_t packetIdentifier)
void sendConnect(const std::string &clientId)
void sendSuback(uint16_t packetIdentifier, const std::list< uint8_t > &returnCodes)
void send(iot::mqtt_fast::ControlPacket &controlPacket) const
void sendUnsuback(uint16_t packetIdentifier)
void sendUnsubscribe(const std::list< std::string > &topics)
void sendSubscribe(std::list< Topic > &topics)
void sendPublish(const std::string &topic, const std::string &message, bool dup=false, uint8_t qoS=0, bool retain=false)
virtual void onUnsuback(const iot::mqtt_fast::packets::Unsuback &unsuback)=0
virtual void onSubscribe(const iot::mqtt_fast::packets::Subscribe &subscribe)=0
void sendPuback(uint16_t packetIdentifier)
virtual void onConnack(const iot::mqtt_fast::packets::Connack &connack)=0
void send(std::vector< char > &&data) const
static void printData(const std::vector< char > &data)
uint16_t getPacketIdentifier()
virtual void onUnsubscribe(const iot::mqtt_fast::packets::Unsubscribe &unsubscribe)=0
virtual void onPubrec(const iot::mqtt_fast::packets::Pubrec &pubrec)=0
virtual void onPublish(const iot::mqtt_fast::packets::Publish &publish)=0
std::size_t onReceivedFromPeer() final
void send(iot::mqtt_fast::ControlPacket &&controlPacket) const
void sendConnack(uint8_t returnCode, uint8_t flags)
virtual void onPingreq(const iot::mqtt_fast::packets::Pingreq &pingreq)=0
Connack(uint8_t reason, uint8_t flags)
Connack(mqtt_fast::ControlPacketFactory &controlPacketFactory)
Connect(const std::string &clientId, const std::string &protocol="MQTT", uint8_t version=4, uint8_t flags=0, uint16_t keepAlive=0x003C)
Connect(iot::mqtt_fast::ControlPacketFactory &controlPacketFactory)
Disconnect(iot::mqtt_fast::ControlPacketFactory &controlPacketFactory)
Pingreq(iot::mqtt_fast::ControlPacketFactory &controlPacketFactory)
Pingresp(iot::mqtt_fast::ControlPacketFactory &controlPacketFactory)
Puback(uint16_t packetIdentifier)
Puback(iot::mqtt_fast::ControlPacketFactory &controlPacketFactory)
Pubcomp(uint16_t packetIdentifier)
Pubcomp(iot::mqtt_fast::ControlPacketFactory &controlPacketFactory)
Publish(iot::mqtt_fast::ControlPacketFactory &controlPacketFactory)
Publish(uint16_t packetIdentifier, const std::string &topic, const std::string &message, bool dup=false, uint8_t qoS=0, bool retain=false)
Pubrec(uint16_t packetIdentifier)
Pubrec(iot::mqtt_fast::ControlPacketFactory &controlPacketFactory)
Pubrel(iot::mqtt_fast::ControlPacketFactory &controlPacketFactory)
Pubrel(uint16_t packetIdentifier)
Suback(uint16_t packetIdentifier, const std::list< uint8_t > &returnCodes)
Suback(iot::mqtt_fast::ControlPacketFactory &controlPacketFactory)
Subscribe(uint16_t packetIdentifier, const std::list< iot::mqtt_fast::Topic > &topics)
Subscribe(iot::mqtt_fast::ControlPacketFactory &controlPacketFactory)
Unsuback(uint16_t packetIdentifier)
Unsuback(iot::mqtt_fast::ControlPacketFactory &controlPacketFactory)
Unsubscribe(iot::mqtt_fast::ControlPacketFactory &controlPacketFactory)
Unsubscribe(uint16_t packetIdentifier, const std::list< std::string > &topics)
std::vector< char > & getValue()