Closed windsql closed 6 years ago
The buffer interface already supports it by default. For example:
var data = new byte[packet.Content.ReadableBytes]; packet.Content.ReadBytes(data);
Something about it is different. Using that to get the bytes I start seeing unconsumed data left in the buffer messages.
@gamemachine What do you mean?
I mean upgrading and changing nothing but one line of code to use what you said to use above to get the byte array, and I get unconsumed data left in buffer errors. Whether it's directly or indirectly related I have no idea.
This is the original implementation, it is not so different anyway. It was removed because everything can be done through public byte buffer interfaces. @gamemachine note that it does not advance the reader index In your case, it is probably equal to the following: var data = new byte[packet.Content.ReadableBytes]; packet.Content.GetBytes(packet.Content.ReaderIndex, data);
public virtual byte[] ToArray()
{
int readableBytes = this.ReadableBytes;
if (readableBytes == 0)
{
return ArrayExtensions.ZeroBytes;
}
if (this.HasArray)
{
return this.Array.Slice(this.ArrayOffset + this.ReaderIndex, readableBytes);
}
var bytes = new byte[readableBytes];
this.GetBytes(this.ReaderIndex, bytes);
return bytes;
}
when update to DotNetty.Buffers from 0.4.6 to 0.4.7 The ToArray method has removed from IByteBuffer interface Is there a method could instead of it.