Search Unity

OnClientDisconnectCallback not called on host when host shuts down

Discussion in 'Netcode for GameObjects' started by AaronKB, May 16, 2022.

  1. AaronKB

    AaronKB

    Joined:
    Aug 16, 2019
    Posts:
    27
    Unity:2021.3.1f1
    NGO:1.0.0-pre.9

    So in order to keep things clean I was expecting to be able to just attach to client disconnection messages so that when running as a client or a host I could get called when the host goes down.

    When I shutdown a standalone cllient, and then NetworkManager.Shutdown the host, the client gets a disconnect callback saying the host client has gone - this is as desired. However the host itself doesn't get a disconnected callback. However, during StartHost(), the host will get a connected callback, so the behaviour seems asymmetrical.

    The downside is that if I have other objects monitoring the client disconnections they are not informed on the host and I have to then add another layer of abstraction, or manually call all the things I need done via some other mechanism.

    Is this expected behaviour and if so, what is the best practice for this? Am I missing some API that I should be using instead?

    Cheers
     
    Last edited: May 16, 2022