diff options
author | George Hazan <ghazan@miranda.im> | 2019-06-26 23:07:24 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-06-26 23:07:24 +0300 |
commit | 718e96a95c5596fa6c7e21984cf8bdfb6d528e60 (patch) | |
tree | e36882173cfed94a825ae1f97b9916022bd5b98e /protocols/Facebook/src/mqtt.h | |
parent | 84b095e0faa33bd6af98f89dabf6b4e54312f113 (diff) |
MQTT: proper MQTT payload preparation
Diffstat (limited to 'protocols/Facebook/src/mqtt.h')
-rw-r--r-- | protocols/Facebook/src/mqtt.h | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/protocols/Facebook/src/mqtt.h b/protocols/Facebook/src/mqtt.h index 5b8147e5f2..55c071d0e3 100644 --- a/protocols/Facebook/src/mqtt.h +++ b/protocols/Facebook/src/mqtt.h @@ -34,21 +34,52 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define FB_THRIFT_TYPE_SET 14 #define FB_THRIFT_TYPE_LIST 15 +enum FbMqttMessageType +{ + FB_MQTT_MESSAGE_TYPE_CONNECT = 1, + FB_MQTT_MESSAGE_TYPE_CONNACK = 2, + FB_MQTT_MESSAGE_TYPE_PUBLISH = 3, + FB_MQTT_MESSAGE_TYPE_PUBACK = 4, + FB_MQTT_MESSAGE_TYPE_PUBREC = 5, + FB_MQTT_MESSAGE_TYPE_PUBREL = 6, + FB_MQTT_MESSAGE_TYPE_PUBCOMP = 7, + FB_MQTT_MESSAGE_TYPE_SUBSCRIBE = 8, + FB_MQTT_MESSAGE_TYPE_SUBACK = 9, + FB_MQTT_MESSAGE_TYPE_UNSUBSCRIBE = 10, + FB_MQTT_MESSAGE_TYPE_UNSUBACK = 11, + FB_MQTT_MESSAGE_TYPE_PINGREQ = 12, + FB_MQTT_MESSAGE_TYPE_PINGRESP = 13, + FB_MQTT_MESSAGE_TYPE_DISCONNECT = 14 +}; + class FbThrift { MBinBuffer m_buf; public: + __inline void* data() { return m_buf.data(); } + __inline size_t size() { return m_buf.length(); } + FbThrift& operator<<(uint8_t); FbThrift& operator<<(const char *); void writeBool(bool value); void writeBuf(const void *pData, size_t cbLen); - void writeInt32(__int32 value); - void writeInt64(__int64 value); - void writeIntV(__int64 value); - void writeField(int type, int id); + void writeInt16(uint16_t value); + void writeInt32(int32_t value); + void writeInt64(int64_t value); + void writeIntV(uint64_t value); + void writeField(int type); void writeField(int type, int id, int lastid); + void writeList(int iType, int size); +}; + +class MqttMessage : public FbThrift +{ +public: + MqttMessage(FbMqttMessageType type, uint8_t flags, size_t payloadSize); + + void writeStr(const char *str); }; #define FB_MQTT_CONNECT_FLAG_CLR 0x0002 |