Browse Source

fixed index out of range

release/3.x.x
Jan Eggers 7 years ago
parent
commit
d594b1447f
2 changed files with 3 additions and 1 deletions
  1. +1
    -0
      Frameworks/MQTTnet.NetStandard/Implementations/WebSocketStream.cs
  2. +2
    -1
      Frameworks/MQTTnet.UniversalWindows/Implementations/WebSocketStream.cs

+ 1
- 0
Frameworks/MQTTnet.NetStandard/Implementations/WebSocketStream.cs View File

@@ -41,6 +41,7 @@ namespace MQTTnet.Implementations
{
var response = await _webSocket.ReceiveAsync(new ArraySegment<byte>(buffer, currentOffset, count), cancellationToken).ConfigureAwait(false);
currentOffset += response.Count;
count -= response.Count;

if (response.MessageType == WebSocketMessageType.Close)
{


+ 2
- 1
Frameworks/MQTTnet.UniversalWindows/Implementations/WebSocketStream.cs View File

@@ -27,7 +27,8 @@ namespace MQTTnet.Implementations
{
var response = await _webSocket.ReceiveAsync(new ArraySegment<byte>(buffer, currentOffset, count), cancellationToken).ConfigureAwait(false);
currentOffset += response.Count;
count -= response.Count;

if (response.MessageType == WebSocketMessageType.Close)
{
await _webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, string.Empty, cancellationToken).ConfigureAwait(false);


Loading…
Cancel
Save