Ver código fonte

Fix serialization issue of MQTTv5 PubRec packet.

release/3.x.x
Christian Kratky 5 anos atrás
pai
commit
2767d897a4
2 arquivos alterados com 21 adições e 12 exclusões
  1. +18
    -8
      Source/MQTTnet/Formatter/IMqttPacketWriter.cs
  2. +3
    -4
      Source/MQTTnet/Formatter/V5/MqttV500PacketEncoder.cs

+ 18
- 8
Source/MQTTnet/Formatter/IMqttPacketWriter.cs Ver arquivo

@@ -5,15 +5,25 @@
int Length { get; }

void WriteWithLengthPrefix(string value);
void Write(byte returnCode);
void WriteWithLengthPrefix(byte[] payload);
void Write(ushort keepAlivePeriod);
void Write(IMqttPacketWriter propertyWriter);
void WriteVariableLengthInteger(uint length);
void Write(byte[] payload, int v, int length);
void Reset(int v);
void Seek(int v);

void Write(byte value);

void WriteWithLengthPrefix(byte[] value);

void Write(ushort value);

void Write(IMqttPacketWriter value);

void WriteVariableLengthInteger(uint value);

void Write(byte[] value, int offset, int length);

void Reset(int length);

void Seek(int offset);

void FreeBuffer();

byte[] GetBuffer();
}
}

+ 3
- 4
Source/MQTTnet/Formatter/V5/MqttV500PacketEncoder.cs Ver arquivo

@@ -328,10 +328,7 @@ namespace MQTTnet.Formatter.V5
{
ThrowReasonCodeNotSetException();
}

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

var propertiesWriter = new MqttV500PropertiesWriter();
if (packet.Properties != null)
{
@@ -339,6 +336,8 @@ namespace MQTTnet.Formatter.V5
propertiesWriter.WriteUserProperties(packet.Properties.UserProperties);
}

packetWriter.Write(packet.PacketIdentifier.Value);

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


Carregando…
Cancelar
Salvar