Skip to content

Commit

Permalink
Merge branch 'master' into 1989-unable-to-connect-with-unix-socket
Browse files Browse the repository at this point in the history
  • Loading branch information
chkr1011 authored May 14, 2024
2 parents 0f17331 + b476977 commit 2558957
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
* [Core] Optimized packet serialization of PUBACK and PUBREC packets for protocol version 5.0.0 (#1939, thanks to @Y-Sindo).
* [Core] The package inspector is now fully async (#1941).
* [Core] Fixed decoding of DISCONNECT packet with empty body (#1994, thanks to @Y-Sindo).
* [Client] Exposed the _EndPoint_ type to support other endpoint types (like Unix Domain Sockets) in client options (#1919).
* [Client] Fixed support for unix sockets by exposing more options (#1995).
* [Client] Added a dedicated exception when the client is not connected (#1954, thanks to @marcpiulachs).
Expand Down
19 changes: 14 additions & 5 deletions Source/MQTTnet/Formatter/V5/MqttV5PacketDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ MqttPacket DecodeConnectPacket(ArraySegment<byte> body)
var packet = new MqttConnectPacket
{
// If the Request Problem Information is absent, the value of 1 is used.
RequestProblemInformation = true
RequestProblemInformation = true
};

var protocolName = _bufferReader.ReadString();
Expand Down Expand Up @@ -352,7 +352,16 @@ MqttPacket DecodeConnectPacket(ArraySegment<byte> body)

MqttPacket DecodeDisconnectPacket(ArraySegment<byte> body)
{
ThrowIfBodyIsEmpty(body);
// From RFC: 3.14.2.1 Disconnect Reason Code
// Byte 1 in the Variable Header is the Disconnect Reason Code.
// If the Remaining Length is less than 1 the value of 0x00 (Normal disconnection) is used.
if (body.Count == 0)
{
return new MqttDisconnectPacket
{
ReasonCode = MqttDisconnectReasonCode.NormalDisconnection
};
}

_bufferReader.SetBuffer(body.Array, body.Offset, body.Count);

Expand Down Expand Up @@ -386,7 +395,7 @@ MqttPacket DecodeDisconnectPacket(ArraySegment<byte> body)

return packet;
}

MqttPacket DecodePubAckPacket(ArraySegment<byte> body)
{
ThrowIfBodyIsEmpty(body);
Expand Down Expand Up @@ -724,7 +733,7 @@ MqttPacket DecodeUnsubAckPacket(ArraySegment<byte> body)
packet.UserProperties = propertiesReader.CollectedUserProperties;

packet.ReasonCodes = new List<MqttUnsubscribeReasonCode>(_bufferReader.BytesLeft);

while (!_bufferReader.EndOfStream)
{
var reasonCode = (MqttUnsubscribeReasonCode)_bufferReader.ReadByte();
Expand Down Expand Up @@ -770,4 +779,4 @@ static void ThrowIfBodyIsEmpty(ArraySegment<byte> body)
}
}
}
}
}

0 comments on commit 2558957

Please sign in to comment.