mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-20 19:58:57 +08:00
propper buffering in place
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user