Commit b0def7dc779fe73cfc1bf19b0812eb22069af271
1 parent
9e29bb2a
More property handling, dummy and otherwise
Showing
3 changed files
with
17 additions
and
2 deletions
mqtt5properties.cpp
| @@ -108,6 +108,11 @@ void Mqtt5PropertyBuilder::writeUserProperty(const std::string &key, const std:: | @@ -108,6 +108,11 @@ void Mqtt5PropertyBuilder::writeUserProperty(const std::string &key, const std:: | ||
| 108 | write2Str(Mqtt5Properties::UserProperty, key, value); | 108 | write2Str(Mqtt5Properties::UserProperty, key, value); |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | +void Mqtt5PropertyBuilder::writeCorrelationData(const std::string &correlationData) | ||
| 112 | +{ | ||
| 113 | + writeStr(Mqtt5Properties::CorrelationData, correlationData); | ||
| 114 | +} | ||
| 115 | + | ||
| 111 | void Mqtt5PropertyBuilder::writeUint32(Mqtt5Properties prop, const uint32_t x, std::vector<char> &target) | 116 | void Mqtt5PropertyBuilder::writeUint32(Mqtt5Properties prop, const uint32_t x, std::vector<char> &target) |
| 112 | { | 117 | { |
| 113 | size_t pos = target.size(); | 118 | size_t pos = target.size(); |
mqtt5properties.h
| @@ -40,6 +40,7 @@ public: | @@ -40,6 +40,7 @@ public: | ||
| 40 | void writeMessageExpiryInterval(uint32_t val); | 40 | void writeMessageExpiryInterval(uint32_t val); |
| 41 | void writeResponseTopic(const std::string &str); | 41 | void writeResponseTopic(const std::string &str); |
| 42 | void writeUserProperty(const std::string &key, const std::string &value); | 42 | void writeUserProperty(const std::string &key, const std::string &value); |
| 43 | + void writeCorrelationData(const std::string &correlationData); | ||
| 43 | }; | 44 | }; |
| 44 | 45 | ||
| 45 | #endif // MQTT5PROPERTIES_H | 46 | #endif // MQTT5PROPERTIES_H |
mqttpacket.cpp
| @@ -449,7 +449,8 @@ void MqttPacket::handleConnect() | @@ -449,7 +449,8 @@ void MqttPacket::handleConnect() | ||
| 449 | case Mqtt5Properties::CorrelationData: | 449 | case Mqtt5Properties::CorrelationData: |
| 450 | { | 450 | { |
| 451 | const uint16_t len = readTwoBytesToUInt16(); | 451 | const uint16_t len = readTwoBytesToUInt16(); |
| 452 | - readBytes(len); | 452 | + const std::string correlationData(readBytes(len), len); |
| 453 | + publishData.propertyBuilder->writeCorrelationData(correlationData); | ||
| 453 | break; | 454 | break; |
| 454 | } | 455 | } |
| 455 | case Mqtt5Properties::UserProperty: | 456 | case Mqtt5Properties::UserProperty: |
| @@ -640,9 +641,16 @@ void MqttPacket::handleSubscribe() | @@ -640,9 +641,16 @@ void MqttPacket::handleSubscribe() | ||
| 640 | switch (prop) | 641 | switch (prop) |
| 641 | { | 642 | { |
| 642 | case Mqtt5Properties::SubscriptionIdentifier: | 643 | case Mqtt5Properties::SubscriptionIdentifier: |
| 644 | + decodeVariableByteIntAtPos(); | ||
| 643 | break; | 645 | break; |
| 644 | case Mqtt5Properties::UserProperty: | 646 | case Mqtt5Properties::UserProperty: |
| 647 | + { | ||
| 648 | + const uint16_t len = readTwoBytesToUInt16(); | ||
| 649 | + readBytes(len); | ||
| 650 | + const uint16_t len2 = readTwoBytesToUInt16(); | ||
| 651 | + readBytes(len2); | ||
| 645 | break; | 652 | break; |
| 653 | + } | ||
| 646 | default: | 654 | default: |
| 647 | throw ProtocolError("Invalid subscribe property."); | 655 | throw ProtocolError("Invalid subscribe property."); |
| 648 | } | 656 | } |
| @@ -839,7 +847,8 @@ void MqttPacket::handlePublish() | @@ -839,7 +847,8 @@ void MqttPacket::handlePublish() | ||
| 839 | case Mqtt5Properties::CorrelationData: | 847 | case Mqtt5Properties::CorrelationData: |
| 840 | { | 848 | { |
| 841 | const uint16_t len = readTwoBytesToUInt16(); | 849 | const uint16_t len = readTwoBytesToUInt16(); |
| 842 | - readBytes(len); | 850 | + const std::string correlationData(readBytes(len), len); |
| 851 | + publishData.propertyBuilder->writeCorrelationData(correlationData); | ||
| 843 | break; | 852 | break; |
| 844 | } | 853 | } |
| 845 | case Mqtt5Properties::UserProperty: | 854 | case Mqtt5Properties::UserProperty: |