Very frustrating. If a client just closes their app (without calling disconnect) there is a lot of errors on the server, but apparently nothing to do. The code below is NEVER called! I’ve seen many posts on this and some claim it works, but in my experiences there is nothing to do. Clients stick around on server, just throwing a bunch of server errors. I sincerely hope somebody knows a fix for this ![]()
public class MyNetworkManager : NetworkManager
{
// called when a client disconnects
public override void OnServerDisconnect(NetworkConnection conn)
{
base.OnServerDisconnect(conn);
Debug.Log("Player disconnected!");
NetworkServer.DestroyPlayersForConnection(conn);
}
// called when disconnected from a server
public override void OnClientDisconnect(NetworkConnection conn)
{
base.OnClientDisconnect(conn);
Debug.Log("Client disconnected!");
}
// called when a network error occurs
public override void OnServerError(NetworkConnection conn, int errorCode)
{
base.OnServerError(conn, errorCode);
Debug.Log("Server error!");
}
// called when a network error occurs
public override void OnClientError(NetworkConnection conn, int errorCode)
{
base.OnClientError(conn, errorCode);
Debug.Log("Client error!");
}
}