9using System.Collections.Generic;
17 Queue<NetworkWriterPooled> batches =
new Queue<NetworkWriterPooled>();
19 public int BatchesCount => batches.Count;
27 double readerRemoteTimeStamp;
37 readerRemoteTimeStamp = reader.ReadDouble();
43 public bool AddBatch(ArraySegment<byte> batch)
51 if (batch.Count <
Batcher.HeaderSize)
59 writer.WriteBytes(batch.Array, batch.Offset, batch.Count);
62 if (batches.Count == 0)
63 StartReadingBatch(writer);
66 batches.Enqueue(writer);
73 public bool GetNextMessage(out
NetworkReader message, out
double remoteTimeStamp)
97 if (batches.Count == 0)
118 if (batches.Count > 0)
123 StartReadingBatch(next);
135 remoteTimeStamp = readerRemoteTimeStamp;
Network Reader for most simple types like floats, ints, buffers, structs, etc. Use NetworkReaderPool....
int Length
Total number of bytes to read from buffer
int Remaining
Remaining bytes that can be read, for convenience.
ArraySegment< byte > ToArraySegment()
Returns allocation-free ArraySegment until 'Position'.
Pool of NetworkWriters to avoid allocations.
static void Return(NetworkWriterPooled writer)
Return a writer to the pool.
static NetworkWriterPooled Get()
Get a writer from the pool. Creates new one if pool is empty.
Pooled NetworkWriter, automatically returned to pool when using 'using'