Adds PacketDecoder & Makes NetState testable (#286)

This commit is contained in:
Kamron Batman 2020-10-24 21:49:28 -07:00 • committed by GitHub
parent e0da7209f6
commit 3337cfa4e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 177 additions and 35 deletions

View file

@ -161,7 +161,17 @@ namespace Server.Buffers
throw new OutOfMemoryException();
}
Position += encoding.GetBytes(src, _buffer.Slice(Position));
var bytesWritten = encoding.GetBytes(src, _buffer.Slice(Position));
Position += bytesWritten;
if (fixedLength > -1)
{
var extra = fixedLength * sizeT - bytesWritten;
if (extra > 0)
{
Clear(extra);
}
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]