|
@@ -25,7 +25,13 @@ namespace MQTTnet.Core.Serializer |
|
|
|
|
|
|
|
|
public static MqttPacketHeader ReadHeaderFromSource(Stream stream, CancellationToken cancellationToken) |
|
|
public static MqttPacketHeader ReadHeaderFromSource(Stream stream, CancellationToken cancellationToken) |
|
|
{ |
|
|
{ |
|
|
var fixedHeader = (byte)stream.ReadByte(); |
|
|
|
|
|
|
|
|
var buffer = stream.ReadByte(); |
|
|
|
|
|
if (buffer == -1) |
|
|
|
|
|
{ |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var fixedHeader = (byte)buffer; |
|
|
var controlPacketType = (MqttControlPacketType)(fixedHeader >> 4); |
|
|
var controlPacketType = (MqttControlPacketType)(fixedHeader >> 4); |
|
|
var bodyLength = ReadBodyLengthFromSource(stream, cancellationToken); |
|
|
var bodyLength = ReadBodyLengthFromSource(stream, cancellationToken); |
|
|
|
|
|
|
|
@@ -83,10 +89,10 @@ namespace MQTTnet.Core.Serializer |
|
|
var buffer = stream.ReadByte(); |
|
|
var buffer = stream.ReadByte(); |
|
|
readBytes.Add(buffer); |
|
|
readBytes.Add(buffer); |
|
|
|
|
|
|
|
|
////if (buffer == -1) |
|
|
|
|
|
////{ |
|
|
|
|
|
//// break; |
|
|
|
|
|
////} |
|
|
|
|
|
|
|
|
if (buffer == -1) |
|
|
|
|
|
{ |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
encodedByte = (byte)buffer; |
|
|
encodedByte = (byte)buffer; |
|
|
value += (byte)(encodedByte & 127) * multiplier; |
|
|
value += (byte)(encodedByte & 127) * multiplier; |
|
|