Definition at line 16 of file Batcher.cs.
◆ Batcher()
Mirror.Batcher.Batcher |
( |
int |
threshold | ) |
|
Definition at line 46 of file Batcher.cs.
47 {
48 this.threshold = threshold;
49 }
◆ AddMessage()
void Mirror.Batcher.AddMessage |
( |
ArraySegment< byte > |
message, |
|
|
double |
timeStamp |
|
) |
| |
Definition at line 54 of file Batcher.cs.
55 {
56
57
58
59
60
61 if (batch != null &&
62 batch.
Position + message.Count > threshold)
63 {
64 batches.Enqueue(batch);
65 batch = null;
66 }
67
68
69 if (batch == null)
70 {
71
72 batch = NetworkWriterPool.Get();
73
74
75
76
77
78 batch.WriteDouble(timeStamp);
79 }
80
81
82
83
84
85 batch.WriteBytes(message.Array, message.Offset, message.Count);
86 }
int Position
Next position to write to the buffer
◆ GetBatch()
Definition at line 106 of file Batcher.cs.
107 {
108
109 if (batches.TryDequeue(out NetworkWriterPooled first))
110 {
111 CopyAndReturn(first, writer);
112 return true;
113 }
114
115
116 if (batch != null)
117 {
118 CopyAndReturn(batch, writer);
119 batch = null;
120 return true;
121 }
122
123
124 return false;
125 }
◆ HeaderSize
const int Mirror.Batcher.HeaderSize = sizeof(double) |
|
static |