@@ -65,7 +65,7 @@ public uint MyClientId
6565 }
6666 }
6767 internal uint myClientId ;
68- internal Dictionary < uint , NetworkedClient > connectedClients ;
68+ internal readonly Dictionary < uint , NetworkedClient > connectedClients = new Dictionary < uint , NetworkedClient > ( ) ;
6969 /// <summary>
7070 /// Gets a dictionary of connected clients
7171 /// </summary>
@@ -76,7 +76,7 @@ public Dictionary<uint, NetworkedClient> ConnectedClients
7676 return connectedClients ;
7777 }
7878 }
79- internal HashSet < uint > pendingClients ;
79+ internal readonly HashSet < uint > pendingClients = new HashSet < uint > ( ) ;
8080 internal bool _isServer ;
8181 internal bool _isClient ;
8282 /// <summary>
@@ -146,7 +146,7 @@ public bool IsClientConnected
146146 public NetworkConfig NetworkConfig ;
147147
148148 internal EllipticDiffieHellman clientDiffieHellman ;
149- internal Dictionary < uint , byte [ ] > diffieHellmanPublicKeys ;
149+ internal readonly Dictionary < uint , byte [ ] > diffieHellmanPublicKeys = new Dictionary < uint , byte [ ] > ( ) ;
150150 internal byte [ ] clientAesKey ;
151151
152152 /// <summary>
@@ -220,26 +220,26 @@ private object Init(bool server)
220220 lastEventTickTime = 0f ;
221221 lastReceiveTickTime = 0f ;
222222 eventOvershootCounter = 0f ;
223- pendingClients = new HashSet < uint > ( ) ;
224- connectedClients = new Dictionary < uint , NetworkedClient > ( ) ;
223+ pendingClients . Clear ( ) ;
224+ connectedClients . Clear ( ) ;
225225 messageBuffer = new byte [ NetworkConfig . MessageBufferSize ] ;
226- diffieHellmanPublicKeys = new Dictionary < uint , byte [ ] > ( ) ;
227- Data . Cache . messageAttributeHashes = new Dictionary < string , ulong > ( ) ;
228- Data . Cache . messageAttributeNames = new Dictionary < ulong , string > ( ) ;
229- MessageManager . channels = new Dictionary < string , int > ( ) ;
230- MessageManager . messageTypes = new Dictionary < string , ushort > ( ) ;
231- MessageManager . messageCallbacks = new Dictionary < ushort , Dictionary < int , Action < uint , BitReader > > > ( ) ;
232- MessageManager . messageHandlerCounter = new Dictionary < ushort , int > ( ) ;
233- MessageManager . releasedMessageHandlerCounters = new Dictionary < ushort , Stack < int > > ( ) ;
234- MessageManager . reverseChannels = new Dictionary < int , string > ( ) ;
235- MessageManager . reverseMessageTypes = new Dictionary < ushort , string > ( ) ;
236- SpawnManager . spawnedObjects = new Dictionary < uint , NetworkedObject > ( ) ;
237- SpawnManager . releasedNetworkObjectIds = new Stack < uint > ( ) ;
238- NetworkPoolManager . Pools = new Dictionary < ushort , NetworkPool > ( ) ;
239- NetworkPoolManager . PoolNamesToIndexes = new Dictionary < string , ushort > ( ) ;
240- NetworkSceneManager . registeredSceneNames = new HashSet < string > ( ) ;
241- NetworkSceneManager . sceneIndexToString = new Dictionary < uint , string > ( ) ;
242- NetworkSceneManager . sceneNameToIndex = new Dictionary < string , uint > ( ) ;
226+ diffieHellmanPublicKeys . Clear ( ) ;
227+ Data . Cache . messageAttributeHashes . Clear ( ) ;
228+ Data . Cache . messageAttributeNames . Clear ( ) ;
229+ MessageManager . channels . Clear ( ) ;
230+ MessageManager . messageTypes . Clear ( ) ;
231+ MessageManager . messageCallbacks . Clear ( ) ;
232+ MessageManager . messageHandlerCounter . Clear ( ) ;
233+ MessageManager . releasedMessageHandlerCounters . Clear ( ) ;
234+ MessageManager . reverseChannels . Clear ( ) ;
235+ MessageManager . reverseMessageTypes . Clear ( ) ;
236+ SpawnManager . spawnedObjects . Clear ( ) ;
237+ SpawnManager . releasedNetworkObjectIds . Clear ( ) ;
238+ NetworkPoolManager . Pools . Clear ( ) ;
239+ NetworkPoolManager . PoolNamesToIndexes . Clear ( ) ;
240+ NetworkSceneManager . registeredSceneNames . Clear ( ) ;
241+ NetworkSceneManager . sceneIndexToString . Clear ( ) ;
242+ NetworkSceneManager . sceneNameToIndex . Clear ( ) ;
243243 InternalMessageHandler . FinalMessageBuffer = new byte [ NetworkConfig . MessageBufferSize ] ;
244244
245245 if ( NetworkConfig . Transport == DefaultTransport . UNET )
0 commit comments