I have a simple setup with host and client(s), and they all listen to OnClientDisconnected.
I noticed that when calling NetworkManager.Singleton.Shutdown() on the server side, the clients have only one means of determining the server shutting down (besides writing RPC calls), as follows:
- client subscribes to NetworkManager’s OnClientDisconnected
- client checks whether the disconnecting clientId is that of the server
Example code snippet that works to confirm on client-side that the host has shut down:
private void OnClientDisconnected(ulong clientId)
{
if (clientId == NetworkManager.ServerClientId)
Debug.LogWarning("server shutting down");
}
Client NetworkManager’s status is still “ConnectedClient == true” and “ShutdownInProgress == false” when the host disconnect callback runs.
I just wonder whether that is the proper way of determining on the client side that the host (server) is shutting down?
(again: besides RPC calls)