Does NetworkManager.Singleton.ConnectedClients automatically purge disconnected Client IDs?

Does anyone know if NetworkManager.Singleton.ConnectedClients automatically purges Client ID keys that are disconnected? Or does it need to be done manually? I have a custom heartbeat function that works assuming the purge needs to be done manually.

I didnt test it, but i assume that ( since the NetworkManger holds the “Network ID recycle delay” variable ) it deletes it after a certain amount of time.

You can easily do a test on that. Just write a script that checks the size or the values inside the ConnectedClientsList and wait for the recycling delay that you can sett inside the NetworkManager.

Yeah, just tested it.

TheConnectedClientsList does remove the clientID when that client disconnects, but I have not seen it recycle that clientID to a new client, even after waiting the recycle delay before connecting. The new client gets ID (2) instead of (1).

I’m assuming it’s because NetworkManager has a simple internal counter that goes up each time a client connects and assigns that as the networkID. Maybe when the counter reaches ulong.maxValue, it will loop back and check for any unused numbers.

1 Like