Fix packet identifier which is sent from the server.

This commit is contained in:
Christian
2018-03-25 14:41:12 +02:00
parent 447b2aa2c6
commit 7a9ddfc2b5
14 changed files with 100 additions and 79 deletions
@@ -138,7 +138,7 @@ namespace MQTTnet.Adapter
}
var body = header.BodyLength <= ReadBufferSize ? new MemoryStream(header.BodyLength) : new MemoryStream();
var buffer = new byte[ReadBufferSize];
while (body.Length < header.BodyLength)
{
@@ -149,7 +149,7 @@ namespace MQTTnet.Adapter
}
var readBytesCount = await stream.ReadAsync(buffer, 0, bytesLeft, cancellationToken).ConfigureAwait(false);
// Check if the client closed the connection before sending the full body.
if (readBytesCount == 0)
{
@@ -162,7 +162,7 @@ namespace MQTTnet.Adapter
}
body.Seek(0L, SeekOrigin.Begin);
return new ReceivedMqttPacket(header, body);
}
@@ -190,7 +190,7 @@ namespace MQTTnet.Adapter
}
catch (COMException comException)
{
if ((uint) comException.HResult == ErrorOperationAborted)
if ((uint)comException.HResult == ErrorOperationAborted)
{
throw new OperationCanceledException();
}
@@ -1,17 +0,0 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using MQTTnet.Packets;
namespace MQTTnet.Adapter
{
public static class MqttChannelAdapterExtensions
{
public static Task SendPacketsAsync(this IMqttChannelAdapter adapter, TimeSpan timeout, CancellationToken cancellationToken, params MqttBasePacket[] packets)
{
if (adapter == null) throw new ArgumentNullException(nameof(adapter));
return adapter.SendPacketsAsync(timeout, cancellationToken, packets);
}
}
}