Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

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

Discussion in 'Netcode for GameObjects' started by yosimba2000, Jun 27, 2022.

  1. yosimba2000

    yosimba2000

    Joined:
    Jun 3, 2021
    Posts:
    25
    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.
     
  2. itisMarcii_

    itisMarcii_

    Joined:
    Apr 5, 2022
    Posts:
    107
    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.
     
  3. yosimba2000

    yosimba2000

    Joined:
    Jun 3, 2021
    Posts:
    25
    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.
     
    itisMarcii_ likes this.