@@ -224,19 +224,19 @@ internal static void Send(List<uint> clientIds, string messageType, string chann
224
224
}
225
225
}
226
226
227
+ private static List < uint > failedObservers = new List < uint > ( ) ;
227
228
//RETURNS THE CLIENTIDS WHICH WAS NOT BEING OBSERVED
228
- internal static List < uint > Send ( string messageType , string channelName , byte [ ] data , uint ? fromNetId , uint ? networkId = null , ushort ? orderId = null )
229
+ internal static ref List < uint > Send ( string messageType , string channelName , byte [ ] data , uint ? fromNetId , uint ? networkId = null , ushort ? orderId = null )
229
230
{
231
+ failedObservers . Clear ( ) ;
230
232
if ( netManager . connectedClients . Count == 0 )
231
- return null ;
233
+ return ref failedObservers ;
232
234
if ( netManager . NetworkConfig . EncryptedChannels . Contains ( channelName ) )
233
235
{
234
236
Debug . LogWarning ( "MLAPI: Cannot send messages over encrypted channel to multiple clients." ) ;
235
- return null ;
237
+ return ref failedObservers ;
236
238
}
237
239
238
- List < uint > nonObservedIds = new List < uint > ( ) ;
239
-
240
240
using ( BitWriter writer = new BitWriter ( ) )
241
241
{
242
242
writer . WriteUShort ( MessageManager . messageTypes [ messageType ] ) ;
@@ -272,7 +272,7 @@ internal static List<uint> Send(string messageType, string channelName, byte[] d
272
272
//If we respect the observers, and the message is targeted (networkId != null) and the targetedNetworkId isnt observing the receiver. Then we continue
273
273
if ( netManager . isServer && fromNetId != null && ! SpawnManager . spawnedObjects [ fromNetId . Value ] . observers . Contains ( pair . Key ) )
274
274
{
275
- nonObservedIds . Add ( pair . Key ) ;
275
+ failedObservers . Add ( pair . Key ) ;
276
276
continue ;
277
277
}
278
278
@@ -281,21 +281,20 @@ internal static List<uint> Send(string messageType, string channelName, byte[] d
281
281
byte error ;
282
282
netManager . NetworkConfig . NetworkTransport . QueueMessageForSending ( targetClientId , ref FinalMessageBuffer , ( int ) writer . GetFinalizeSize ( ) , channel , false , out error ) ;
283
283
}
284
- return nonObservedIds ;
284
+ return ref failedObservers ;
285
285
}
286
286
}
287
287
288
288
//RETURNS THE CLIENTIDS WHICH WAS NOT BEING OBSERVED
289
- internal static List < uint > Send ( string messageType , string channelName , byte [ ] data , uint clientIdToIgnore , uint ? fromNetId , uint ? networkId = null , ushort ? orderId = null )
289
+ internal static ref List < uint > Send ( string messageType , string channelName , byte [ ] data , uint clientIdToIgnore , uint ? fromNetId , uint ? networkId = null , ushort ? orderId = null )
290
290
{
291
+ failedObservers . Clear ( ) ;
291
292
if ( netManager . NetworkConfig . EncryptedChannels . Contains ( channelName ) )
292
293
{
293
294
Debug . LogWarning ( "MLAPI: Cannot send messages over encrypted channel to multiple clients." ) ;
294
- return null ;
295
+ return ref failedObservers ;
295
296
}
296
297
297
- List < uint > nonObservedIds = new List < uint > ( ) ;
298
-
299
298
using ( BitWriter writer = new BitWriter ( ) )
300
299
{
301
300
writer . WriteUShort ( MessageManager . messageTypes [ messageType ] ) ;
@@ -334,7 +333,7 @@ internal static List<uint> Send(string messageType, string channelName, byte[] d
334
333
//If we respect the observers, and the message is targeted (networkId != null) and the targetedNetworkId isnt observing the receiver. Then we continue
335
334
if ( netManager . isServer && fromNetId != null && ! SpawnManager . spawnedObjects [ fromNetId . Value ] . observers . Contains ( pair . Key ) )
336
335
{
337
- nonObservedIds . Add ( pair . Key ) ;
336
+ failedObservers . Add ( pair . Key ) ;
338
337
continue ;
339
338
}
340
339
@@ -343,7 +342,7 @@ internal static List<uint> Send(string messageType, string channelName, byte[] d
343
342
byte error ;
344
343
netManager . NetworkConfig . NetworkTransport . QueueMessageForSending ( targetClientId , ref FinalMessageBuffer , ( int ) writer . GetFinalizeSize ( ) , channel , false , out error ) ;
345
344
}
346
- return nonObservedIds ;
345
+ return ref failedObservers ;
347
346
}
348
347
}
349
348
}
0 commit comments