@@ -66,14 +66,15 @@ public uint MyClientId
6666 }
6767 internal uint myClientId ;
6868 internal readonly Dictionary < uint , NetworkedClient > connectedClients = new Dictionary < uint , NetworkedClient > ( ) ;
69+ internal readonly List < NetworkedClient > connectedClientsList = new List < NetworkedClient > ( ) ;
6970 /// <summary>
70- /// Gets a dictionary of connected clients
71+ /// Gets a list of connected clients
7172 /// </summary>
72- public Dictionary < uint , NetworkedClient > ConnectedClients
73+ public List < NetworkedClient > ConnectedClients
7374 {
7475 get
7576 {
76- return connectedClients ;
77+ return connectedClientsList ;
7778 }
7879 }
7980 internal readonly HashSet < uint > pendingClients = new HashSet < uint > ( ) ;
@@ -222,6 +223,7 @@ private object Init(bool server)
222223 eventOvershootCounter = 0f ;
223224 pendingClients . Clear ( ) ;
224225 connectedClients . Clear ( ) ;
226+ connectedClientsList . Clear ( ) ;
225227 messageBuffer = new byte [ NetworkConfig . MessageBufferSize ] ;
226228 diffieHellmanPublicKeys . Clear ( ) ;
227229 Data . Cache . messageAttributeHashes . Clear ( ) ;
@@ -607,6 +609,7 @@ public void StartHost(Vector3? pos = null, Quaternion? rot = null)
607609 {
608610 ClientId = hostClientId
609611 } ) ;
612+ connectedClientsList . Add ( connectedClients [ hostClientId ] ) ;
610613
611614 if ( NetworkConfig . HandleObjectSpawning )
612615 {
@@ -996,6 +999,8 @@ internal void DisconnectClient(uint clientId)
996999
9971000 if ( connectedClients . ContainsKey ( clientId ) )
9981001 connectedClients . Remove ( clientId ) ;
1002+
1003+ connectedClientsList . RemoveAll ( x => x . ClientId == clientId ) ; // :(
9991004
10001005 if ( diffieHellmanPublicKeys . ContainsKey ( clientId ) )
10011006 diffieHellmanPublicKeys . Remove ( clientId ) ;
@@ -1022,6 +1027,7 @@ internal void OnClientDisconnect(uint clientId)
10221027 Destroy ( connectedClients [ clientId ] . OwnedObjects [ i ] . gameObject ) ;
10231028 }
10241029 }
1030+ connectedClientsList . RemoveAll ( x => x . ClientId == clientId ) ;
10251031 connectedClients . Remove ( clientId ) ;
10261032 }
10271033
@@ -1087,6 +1093,7 @@ internal void HandleApproval(uint clientId, bool approved, Vector3 position, Qua
10871093 AesKey = aesKey
10881094 } ;
10891095 connectedClients . Add ( clientId , client ) ;
1096+ connectedClientsList . Add ( client ) ;
10901097
10911098 if ( NetworkConfig . HandleObjectSpawning )
10921099 {
0 commit comments