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