@@ -66,14 +66,15 @@ public uint MyClientId
66
66
}
67
67
internal uint myClientId ;
68
68
internal readonly Dictionary < uint , NetworkedClient > connectedClients = new Dictionary < uint , NetworkedClient > ( ) ;
69
+ internal readonly List < NetworkedClient > connectedClientsList = new List < NetworkedClient > ( ) ;
69
70
/// <summary>
70
- /// Gets a dictionary of connected clients
71
+ /// Gets a list of connected clients
71
72
/// </summary>
72
- public Dictionary < uint , NetworkedClient > ConnectedClients
73
+ public List < NetworkedClient > ConnectedClients
73
74
{
74
75
get
75
76
{
76
- return connectedClients ;
77
+ return connectedClientsList ;
77
78
}
78
79
}
79
80
internal readonly HashSet < uint > pendingClients = new HashSet < uint > ( ) ;
@@ -222,6 +223,7 @@ private object Init(bool server)
222
223
eventOvershootCounter = 0f ;
223
224
pendingClients . Clear ( ) ;
224
225
connectedClients . Clear ( ) ;
226
+ connectedClientsList . Clear ( ) ;
225
227
messageBuffer = new byte [ NetworkConfig . MessageBufferSize ] ;
226
228
diffieHellmanPublicKeys . Clear ( ) ;
227
229
Data . Cache . messageAttributeHashes . Clear ( ) ;
@@ -607,6 +609,7 @@ public void StartHost(Vector3? pos = null, Quaternion? rot = null)
607
609
{
608
610
ClientId = hostClientId
609
611
} ) ;
612
+ connectedClientsList . Add ( connectedClients [ hostClientId ] ) ;
610
613
611
614
if ( NetworkConfig . HandleObjectSpawning )
612
615
{
@@ -996,6 +999,8 @@ internal void DisconnectClient(uint clientId)
996
999
997
1000
if ( connectedClients . ContainsKey ( clientId ) )
998
1001
connectedClients . Remove ( clientId ) ;
1002
+
1003
+ connectedClientsList . RemoveAll ( x => x . ClientId == clientId ) ; // :(
999
1004
1000
1005
if ( diffieHellmanPublicKeys . ContainsKey ( clientId ) )
1001
1006
diffieHellmanPublicKeys . Remove ( clientId ) ;
@@ -1022,6 +1027,7 @@ internal void OnClientDisconnect(uint clientId)
1022
1027
Destroy ( connectedClients [ clientId ] . OwnedObjects [ i ] . gameObject ) ;
1023
1028
}
1024
1029
}
1030
+ connectedClientsList . RemoveAll ( x => x . ClientId == clientId ) ;
1025
1031
connectedClients . Remove ( clientId ) ;
1026
1032
}
1027
1033
@@ -1087,6 +1093,7 @@ internal void HandleApproval(uint clientId, bool approved, Vector3 position, Qua
1087
1093
AesKey = aesKey
1088
1094
} ;
1089
1095
connectedClients . Add ( clientId , client ) ;
1096
+ connectedClientsList . Add ( client ) ;
1090
1097
1091
1098
if ( NetworkConfig . HandleObjectSpawning )
1092
1099
{
0 commit comments