Search Unity

Callback When Unity Networking Is Fully Shut Down

Discussion in 'Multiplayer' started by gamecakestudios, Sep 6, 2016.

  1. gamecakestudios

    gamecakestudios

    Joined:
    Nov 13, 2013
    Posts:
    21
    Hi, I'm having an issue with determining when it is safe to spawn a new NetworkManager and start up a server.

    The way our team's game is built, we allow gameplay over a variety of different networking technologies (UNET, Bluetooth, Chromecast, etc). Therefore, we do not allow the NetworkManager class to control and change the scene on Shutdown() as this is all implemented at a higher, more abstracted layer so it works across all our different networking code.

    We have an edge case where we need to shut down unity networking, and then start it back up as soon as possible, creating a network server almost immediately. Right now, I get a host ID error if I try to run NetworkManager.Shutdown, destroy the MonoBehaviour from the scene, and then spawn another one and call StartServer() all on the same frame. (Not surprising).
    Our current workaround is to wait for 1 second in an update loop, and then start it up again. I really don't like this approach.

    Is there a callback (or multiple callbacks) that will tell me exactly when the Network Server / Client, NetworkTransport, and all other relevant classes have finished cleanly shutting down so that I can safely start up a new server without encountering Host ID or port occupancy errors?

    Thank you!
     
  2. gamecakestudios

    gamecakestudios

    Joined:
    Nov 13, 2013
    Posts:
    21
    Has anyone else encountered this issue before? Would love some feedback on the right way to do this. I can provide more information if it would help. :)
     
  3. gamecakestudios

    gamecakestudios

    Joined:
    Nov 13, 2013
    Posts:
    21
  4. gamecakestudios

    gamecakestudios

    Joined:
    Nov 13, 2013
    Posts:
    21
    Has no one else run into this?
     
  5. chadfranklin47

    chadfranklin47

    Joined:
    Aug 11, 2015
    Posts:
    229
    I'm running into this error, but I don't know why.