- Home /
HLAPI - Old server messages sent on reconnect
I have a LAN multiplayer game with 1 server and N clients. When all the players are ready, the server starts the game scene by calling NetworkManager.ServerChangeScene().
If a client disconnects by closing the game, the game ends and all the remaining players go back to the lobby scene. I also clean some server data to try to reset the server state. NetworkRoot is the parent game object for other network elements.
var networkRoot= FindObjectOfType<NetworkRoot>();
var networkManager = FindObjectOfType<NetworkManager>();
if (_isServer)
{
foreach(var connection in NetworkServer.connections)
{
connection.FlushChannels();
connection.Disconnect();
}
NetworkServer.Shutdown();
}
NetworkClient.ShutdownAll();
NetworkManager.activeTransport.Shutdown();
NetworkManager.Shutdown();
Destroy(networkRoot.gameObject);
Destroy(networkManager.gameObject);
However, if the client that disconnected re-opens the game and connect to the server through the lobby, they're instantly moved to the game scene as if the message to switch scenes from the previous game had arrived to them again.
If I re-start the game on the server device it works properly, so I guess the server must be storing some state that is sent to the client when they reconnect, but I don't know where it is and how to remove it. Is there anything else I must do to wipe the server state?
Any help would be appreciated.