Procházet zdrojové kódy

Fix message encoding bugs.

release/3.x.x
Christian Kratky před 5 roky
rodič
revize
664549ab93
4 změnil soubory, kde provedl 18 přidání a 8 odebrání
  1. +3
    -1
      Build/MQTTnet.nuspec
  2. +7
    -0
      Source/MQTTnet/Formatter/V5/MqttV500DataConverter.cs
  3. +5
    -7
      Source/MQTTnet/Formatter/V5/MqttV500PacketEncoder.cs
  4. +3
    -0
      Source/MQTTnet/Formatter/V5/MqttV500PropertiesWriter.cs

+ 3
- 1
Build/MQTTnet.nuspec Zobrazit soubor

@@ -11,7 +11,9 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>MQTTnet is a high performance .NET library for MQTT based communication. It provides a MQTT client and a MQTT server (broker).</description>
<releaseNotes>
* [Server] Fixed a bug which returns wrong flag for existing sessions (thanks to @avengerstark).
* [Core] Fixed missing properties from PUBLISH packet in _MqttApplicationMessage_ (thanks to @pcbing).
* [Core] Fixed wrong encoding of PUBREL and PUBCOMP packets for MQTTv5 (thanks to @perphilipp).
* [Server] Fixed a bug which returns wrong flag for existing session in CONNACK packet (thanks to @avengerstark).
* [nuget] .NET Framework builds are now using 4.5.2 or 4.6.1 builds instead of netstandard 2.0.
</releaseNotes>
<copyright>Copyright Christian Kratky 2016-2019</copyright>


+ 7
- 0
Source/MQTTnet/Formatter/V5/MqttV500DataConverter.cs Zobrazit soubor

@@ -63,6 +63,13 @@ namespace MQTTnet.Formatter.V5
Payload = publishPacket.Payload,
QualityOfServiceLevel = publishPacket.QualityOfServiceLevel,
Retain = publishPacket.Retain,
ResponseTopic = publishPacket.Properties?.ResponseTopic,
ContentType = publishPacket.Properties?.ContentType,
CorrelationData = publishPacket.Properties?.CorrelationData,
MessageExpiryInterval = publishPacket.Properties?.MessageExpiryInterval,
SubscriptionIdentifier = publishPacket.Properties?.SubscriptionIdentifier,
TopicAlias = publishPacket.Properties?.TopicAlias,
PayloadFormatIndicator = publishPacket.Properties?.PayloadFormatIndicator,
UserProperties = publishPacket.Properties?.UserProperties ?? new List<MqttUserProperty>()
};
}


+ 5
- 7
Source/MQTTnet/Formatter/V5/MqttV500PacketEncoder.cs Zobrazit soubor

@@ -343,9 +343,6 @@ namespace MQTTnet.Formatter.V5
ThrowReasonCodeNotSetException();
}

packetWriter.Write(packet.PacketIdentifier.Value);
packetWriter.Write((byte)packet.ReasonCode.Value);

var propertiesWriter = new MqttV500PropertiesWriter();
if (packet.Properties != null)
{
@@ -353,7 +350,9 @@ namespace MQTTnet.Formatter.V5
propertiesWriter.WriteUserProperties(packet.Properties.UserProperties);
}

if (packetWriter.Length > 0 || packet.ReasonCode.Value != MqttPubRelReasonCode.Success)
packetWriter.Write(packet.PacketIdentifier.Value);
if (propertiesWriter.Length > 0 || packet.ReasonCode.Value != MqttPubRelReasonCode.Success)
{
packetWriter.Write((byte)packet.ReasonCode.Value);
propertiesWriter.WriteToPacket(packetWriter);
@@ -372,8 +371,7 @@ namespace MQTTnet.Formatter.V5
}

packetWriter.Write(packet.PacketIdentifier.Value);
packetWriter.Write((byte)packet.ReasonCode.Value);

var propertiesWriter = new MqttV500PropertiesWriter();
if (packet.Properties != null)
{
@@ -381,7 +379,7 @@ namespace MQTTnet.Formatter.V5
propertiesWriter.WriteUserProperties(packet.Properties.UserProperties);
}

if (packetWriter.Length > 0 || packet.ReasonCode.Value != MqttPubCompReasonCode.Success)
if (propertiesWriter.Length > 0 || packet.ReasonCode.Value != MqttPubCompReasonCode.Success)
{
packetWriter.Write((byte)packet.ReasonCode.Value);
propertiesWriter.WriteToPacket(packetWriter);


+ 3
- 0
Source/MQTTnet/Formatter/V5/MqttV500PropertiesWriter.cs Zobrazit soubor

@@ -7,8 +7,11 @@ namespace MQTTnet.Formatter.V5
{
public class MqttV500PropertiesWriter
{
// TODO: Consider lazy init on first write to avoid useless allocations.
private readonly MqttPacketWriter _packetWriter = new MqttPacketWriter();

public int Length => _packetWriter.Length;

public void WriteUserProperties(List<MqttUserProperty> userProperties)
{
if (userProperties == null || userProperties.Count == 0)


Načítá se…
Zrušit
Uložit