@@ -37,6 +37,7 @@ internal class NetworkMetrics : INetworkMetrics
37
37
readonly EventMetric < ServerLogEvent > m_ServerLogReceivedEvent = new EventMetric < ServerLogEvent > ( NetworkMetricTypes . ServerLogReceived . Id ) ;
38
38
readonly EventMetric < SceneEventMetric > m_SceneEventSentEvent = new EventMetric < SceneEventMetric > ( NetworkMetricTypes . SceneEventSent . Id ) ;
39
39
readonly EventMetric < SceneEventMetric > m_SceneEventReceivedEvent = new EventMetric < SceneEventMetric > ( NetworkMetricTypes . SceneEventReceived . Id ) ;
40
+ private bool m_Dirty ;
40
41
41
42
readonly Dictionary < ulong , NetworkObjectIdentifier > m_NetworkGameObjects = new Dictionary < ulong , NetworkObjectIdentifier > ( ) ;
42
43
@@ -87,16 +88,19 @@ public void TrackNetworkObject(NetworkObject networkObject)
87
88
public void TrackNetworkMessageSent ( ulong receivedClientId , string messageType , long bytesCount )
88
89
{
89
90
m_NetworkMessageSentEvent . Mark ( new NetworkMessageEvent ( new ConnectionInfo ( receivedClientId ) , messageType , bytesCount ) ) ;
91
+ MarkDirty ( ) ;
90
92
}
91
93
92
94
public void TrackNetworkMessageReceived ( ulong senderClientId , string messageType , long bytesCount )
93
95
{
94
96
m_NetworkMessageReceivedEvent . Mark ( new NetworkMessageEvent ( new ConnectionInfo ( senderClientId ) , messageType , bytesCount ) ) ;
97
+ MarkDirty ( ) ;
95
98
}
96
99
97
100
public void TrackNamedMessageSent ( ulong receiverClientId , string messageName , long bytesCount )
98
101
{
99
102
m_NamedMessageSentEvent . Mark ( new NamedMessageEvent ( new ConnectionInfo ( receiverClientId ) , messageName , bytesCount ) ) ;
103
+ MarkDirty ( ) ;
100
104
}
101
105
102
106
public void TrackNamedMessageSent ( IReadOnlyCollection < ulong > receiverClientIds , string messageName , long bytesCount )
@@ -110,11 +114,13 @@ public void TrackNamedMessageSent(IReadOnlyCollection<ulong> receiverClientIds,
110
114
public void TrackNamedMessageReceived ( ulong senderClientId , string messageName , long bytesCount )
111
115
{
112
116
m_NamedMessageReceivedEvent . Mark ( new NamedMessageEvent ( new ConnectionInfo ( senderClientId ) , messageName , bytesCount ) ) ;
117
+ MarkDirty ( ) ;
113
118
}
114
119
115
120
public void TrackUnnamedMessageSent ( ulong receiverClientId , long bytesCount )
116
121
{
117
122
m_UnnamedMessageSentEvent . Mark ( new UnnamedMessageEvent ( new ConnectionInfo ( receiverClientId ) , bytesCount ) ) ;
123
+ MarkDirty ( ) ;
118
124
}
119
125
120
126
public void TrackUnnamedMessageSent ( IReadOnlyCollection < ulong > receiverClientIds , long bytesCount )
@@ -128,6 +134,7 @@ public void TrackUnnamedMessageSent(IReadOnlyCollection<ulong> receiverClientIds
128
134
public void TrackUnnamedMessageReceived ( ulong senderClientId , long bytesCount )
129
135
{
130
136
m_UnnamedMessageReceivedEvent . Mark ( new UnnamedMessageEvent ( new ConnectionInfo ( senderClientId ) , bytesCount ) ) ;
137
+ MarkDirty ( ) ;
131
138
}
132
139
133
140
public void TrackNetworkVariableDeltaSent (
@@ -145,6 +152,7 @@ public void TrackNetworkVariableDeltaSent(
145
152
variableName ,
146
153
networkBehaviourName ,
147
154
bytesCount ) ) ;
155
+ MarkDirty ( ) ;
148
156
}
149
157
150
158
public void TrackNetworkVariableDeltaReceived (
@@ -162,37 +170,44 @@ public void TrackNetworkVariableDeltaReceived(
162
170
variableName ,
163
171
networkBehaviourName ,
164
172
bytesCount ) ) ;
173
+ MarkDirty ( ) ;
165
174
}
166
175
167
176
public void TrackOwnershipChangeSent ( ulong receiverClientId , ulong networkObjectId , string gameObjectName , long bytesCount )
168
177
{
169
178
m_OwnershipChangeSentEvent . Mark ( new OwnershipChangeEvent ( new ConnectionInfo ( receiverClientId ) , new NetworkObjectIdentifier ( gameObjectName , networkObjectId ) , bytesCount ) ) ;
179
+ MarkDirty ( ) ;
170
180
}
171
181
172
182
public void TrackOwnershipChangeReceived ( ulong senderClientId , ulong networkObjectId , string gameObjectName , long bytesCount )
173
183
{
174
184
m_OwnershipChangeReceivedEvent . Mark ( new OwnershipChangeEvent ( new ConnectionInfo ( senderClientId ) ,
175
185
new NetworkObjectIdentifier ( gameObjectName , networkObjectId ) , bytesCount ) ) ;
186
+ MarkDirty ( ) ;
176
187
}
177
188
178
189
public void TrackObjectSpawnSent ( ulong receiverClientId , ulong networkObjectId , string gameObjectName , long bytesCount )
179
190
{
180
191
m_ObjectSpawnSentEvent . Mark ( new ObjectSpawnedEvent ( new ConnectionInfo ( receiverClientId ) , new NetworkObjectIdentifier ( gameObjectName , networkObjectId ) , bytesCount ) ) ;
192
+ MarkDirty ( ) ;
181
193
}
182
194
183
195
public void TrackObjectSpawnReceived ( ulong senderClientId , ulong networkObjectId , string gameObjectName , long bytesCount )
184
196
{
185
197
m_ObjectSpawnReceivedEvent . Mark ( new ObjectSpawnedEvent ( new ConnectionInfo ( senderClientId ) , new NetworkObjectIdentifier ( gameObjectName , networkObjectId ) , bytesCount ) ) ;
198
+ MarkDirty ( ) ;
186
199
}
187
200
188
201
public void TrackObjectDestroySent ( ulong receiverClientId , ulong networkObjectId , string gameObjectName , long bytesCount )
189
202
{
190
203
m_ObjectDestroySentEvent . Mark ( new ObjectDestroyedEvent ( new ConnectionInfo ( receiverClientId ) , new NetworkObjectIdentifier ( gameObjectName , networkObjectId ) , bytesCount ) ) ;
204
+ MarkDirty ( ) ;
191
205
}
192
206
193
207
public void TrackObjectDestroyReceived ( ulong senderClientId , ulong networkObjectId , string gameObjectName , long bytesCount )
194
208
{
195
209
m_ObjectDestroyReceivedEvent . Mark ( new ObjectDestroyedEvent ( new ConnectionInfo ( senderClientId ) , new NetworkObjectIdentifier ( gameObjectName , networkObjectId ) , bytesCount ) ) ;
210
+ MarkDirty ( ) ;
196
211
}
197
212
198
213
public void TrackRpcSent (
@@ -214,6 +229,7 @@ public void TrackRpcSent(
214
229
rpcName ,
215
230
networkBehaviourName ,
216
231
bytesCount ) ) ;
232
+ MarkDirty ( ) ;
217
233
}
218
234
219
235
public void TrackRpcSent (
@@ -247,16 +263,19 @@ public void TrackRpcReceived(
247
263
rpcName ,
248
264
networkBehaviourName ,
249
265
bytesCount ) ) ;
266
+ MarkDirty ( ) ;
250
267
}
251
268
252
269
public void TrackServerLogSent ( ulong receiverClientId , uint logType , long bytesCount )
253
270
{
254
271
m_ServerLogSentEvent . Mark ( new ServerLogEvent ( new ConnectionInfo ( receiverClientId ) , ( Unity . Multiplayer . Tools . MetricTypes . LogLevel ) logType , bytesCount ) ) ;
272
+ MarkDirty ( ) ;
255
273
}
256
274
257
275
public void TrackServerLogReceived ( ulong senderClientId , uint logType , long bytesCount )
258
276
{
259
277
m_ServerLogReceivedEvent . Mark ( new ServerLogEvent ( new ConnectionInfo ( senderClientId ) , ( Unity . Multiplayer . Tools . MetricTypes . LogLevel ) logType , bytesCount ) ) ;
278
+ MarkDirty ( ) ;
260
279
}
261
280
262
281
public void TrackSceneEventSent ( IReadOnlyList < ulong > receiverClientIds , uint sceneEventType , string sceneName , long bytesCount )
@@ -270,16 +289,27 @@ public void TrackSceneEventSent(IReadOnlyList<ulong> receiverClientIds, uint sce
270
289
public void TrackSceneEventSent ( ulong receiverClientId , uint sceneEventType , string sceneName , long bytesCount )
271
290
{
272
291
m_SceneEventSentEvent . Mark ( new SceneEventMetric ( new ConnectionInfo ( receiverClientId ) , ( SceneEventType ) sceneEventType , sceneName , bytesCount ) ) ;
292
+ MarkDirty ( ) ;
273
293
}
274
294
275
295
public void TrackSceneEventReceived ( ulong senderClientId , uint sceneEventType , string sceneName , long bytesCount )
276
296
{
277
297
m_SceneEventReceivedEvent . Mark ( new SceneEventMetric ( new ConnectionInfo ( senderClientId ) , ( SceneEventType ) sceneEventType , sceneName , bytesCount ) ) ;
298
+ MarkDirty ( ) ;
278
299
}
279
300
280
301
public void DispatchFrame ( )
281
302
{
282
- Dispatcher . Dispatch ( ) ;
303
+ if ( m_Dirty )
304
+ {
305
+ Dispatcher . Dispatch ( ) ;
306
+ m_Dirty = false ;
307
+ }
308
+ }
309
+
310
+ private void MarkDirty ( )
311
+ {
312
+ m_Dirty = true ;
283
313
}
284
314
}
285
315
0 commit comments