mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
Flush when starting or finishing a message. (#4)
This is a no-op with BinaryWriter/MemoryStream, but this is necesary if we do any sort of transformation, such as BitWriter, compression or encryption
This commit is contained in:
parent
ec48bcc496
commit
cdd4eac7a1
@ -23,6 +23,7 @@ public class NetworkWriter
|
|||||||
// => .ToArray() would return 10 bytes because of the first write, which is exactly what we don't want.
|
// => .ToArray() would return 10 bytes because of the first write, which is exactly what we don't want.
|
||||||
public byte[] ToArray()
|
public byte[] ToArray()
|
||||||
{
|
{
|
||||||
|
writer.Flush();
|
||||||
byte[] slice = new byte[Position];
|
byte[] slice = new byte[Position];
|
||||||
Array.Copy(((MemoryStream)writer.BaseStream).ToArray(), slice, Position);
|
Array.Copy(((MemoryStream)writer.BaseStream).ToArray(), slice, Position);
|
||||||
return slice;
|
return slice;
|
||||||
|
Loading…
Reference in New Issue
Block a user