diff --git a/mqtt5properties.cpp b/mqtt5properties.cpp index ae85321..4dc6c75 100644 --- a/mqtt5properties.cpp +++ b/mqtt5properties.cpp @@ -108,6 +108,11 @@ void Mqtt5PropertyBuilder::writeUserProperty(const std::string &key, const std:: write2Str(Mqtt5Properties::UserProperty, key, value); } +void Mqtt5PropertyBuilder::writeCorrelationData(const std::string &correlationData) +{ + writeStr(Mqtt5Properties::CorrelationData, correlationData); +} + void Mqtt5PropertyBuilder::writeUint32(Mqtt5Properties prop, const uint32_t x, std::vector &target) { size_t pos = target.size(); diff --git a/mqtt5properties.h b/mqtt5properties.h index 4b0d6ce..2d9ce1a 100644 --- a/mqtt5properties.h +++ b/mqtt5properties.h @@ -40,6 +40,7 @@ public: void writeMessageExpiryInterval(uint32_t val); void writeResponseTopic(const std::string &str); void writeUserProperty(const std::string &key, const std::string &value); + void writeCorrelationData(const std::string &correlationData); }; #endif // MQTT5PROPERTIES_H diff --git a/mqttpacket.cpp b/mqttpacket.cpp index 34656ee..16dd429 100644 --- a/mqttpacket.cpp +++ b/mqttpacket.cpp @@ -449,7 +449,8 @@ void MqttPacket::handleConnect() case Mqtt5Properties::CorrelationData: { const uint16_t len = readTwoBytesToUInt16(); - readBytes(len); + const std::string correlationData(readBytes(len), len); + publishData.propertyBuilder->writeCorrelationData(correlationData); break; } case Mqtt5Properties::UserProperty: @@ -640,9 +641,16 @@ void MqttPacket::handleSubscribe() switch (prop) { case Mqtt5Properties::SubscriptionIdentifier: + decodeVariableByteIntAtPos(); break; case Mqtt5Properties::UserProperty: + { + const uint16_t len = readTwoBytesToUInt16(); + readBytes(len); + const uint16_t len2 = readTwoBytesToUInt16(); + readBytes(len2); break; + } default: throw ProtocolError("Invalid subscribe property."); } @@ -839,7 +847,8 @@ void MqttPacket::handlePublish() case Mqtt5Properties::CorrelationData: { const uint16_t len = readTwoBytesToUInt16(); - readBytes(len); + const std::string correlationData(readBytes(len), len); + publishData.propertyBuilder->writeCorrelationData(correlationData); break; } case Mqtt5Properties::UserProperty: