propper buffering in place

This commit is contained in:
JanEggers
2017-09-10 18:20:25 +02:00
parent 644bcfba27
commit 9cde49f5f8
14 changed files with 227 additions and 131 deletions
@@ -418,15 +418,21 @@ namespace MQTTnet.Core.Tests
return _stream.WriteAsync(buffer, 0, buffer.Length);
}
public Task ReadAsync(byte[] buffer)
public async Task<ArraySegment<byte>> ReadAsync(int length, byte[] buffer)
{
return _stream.ReadAsync(buffer, 0, buffer.Length);
await _stream.ReadAsync(buffer, 0, length);
return new ArraySegment<byte>(buffer, 0, length);
}
public byte[] ToArray()
{
return _stream.ToArray();
}
public int Peek()
{
return (int)_stream.Length - (int)_stream.Position;
}
}
private static void SerializeAndCompare(MqttBasePacket packet, string expectedBase64Value, MqttProtocolVersion protocolVersion = MqttProtocolVersion.V311)