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

When subscribing to NetworkManager.OnClientDisconnectCallback I get no message on local Shutdown()

Discussion in 'Multiplayer' started by qNaN, Apr 21, 2022.

  1. qNaN

    qNaN

    Joined:
    Dec 29, 2015
    Posts:
    26
    If I subscribe to the NetworkManager.OnClientDisconnectCallback I will get no message if I call NetworkManager.Shutdown() on my client, whether this is as a Host or a Client.

    It seems like the NetworkManager is destroyed before the message is sent?
     
  2. AaronKB

    AaronKB

    Joined:
    Aug 16, 2019
    Posts:
    27
    Did you solve this at all? If I am a host and a call NetworkManager.Shutdown() then I get no disconnected callbacks even though I got a connected callback when the host was started
     
  3. qNaN

    qNaN

    Joined:
    Dec 29, 2015
    Posts:
    26
    No, still not solved, and I haven't heard a word on this.

    Since you know of the event yourself, as you are the client (or host) taking the action, you can just send a message yourself to the object needing the message.
    Personally I have my own central singleton network object that works closely together with the NetworkManager (like an extension really - I call it "CentralNetwork"), and I made a Shutdown() method here, that will in return call NetworkManager::Shutdown(). After that it will notify all listeners to its own event of what happened.

    This works perfectly fine, but it would be easier if it was handled directly by the NetworkManager.
     
    Last edited: May 17, 2022
  4. AaronKB

    AaronKB

    Joined:
    Aug 16, 2019
    Posts:
    27
    Thanks. I've ended up doing something similar but I agree, consistency here would have been nice.