Disconnected detection on client
Hi Guys
Hoping you guys can help me out, i might be missing something obvious...
Question:
I want to be able to detect on the client side that he has been disconnected from the host(E.g. the host decides to call it quits and exits) killing the session for everyone involved. When i look at the disconnect parameter that gets called, i cant see any way of knowing from the properties that it was the server/Host that disconnected, i can only see what the remote endpoint is, how would i decide that it was the host who disconnected.
Scenario:
I want to detect if the host disconnects then attempt to reconnect the player to another hosted session automatically
Hoping you guys can help me out, i might be missing something obvious...
Question:
I want to be able to detect on the client side that he has been disconnected from the host(E.g. the host decides to call it quits and exits) killing the session for everyone involved. When i look at the disconnect parameter that gets called, i cant see any way of knowing from the properties that it was the server/Host that disconnected, i can only see what the remote endpoint is, how would i decide that it was the host who disconnected.
Scenario:
I want to detect if the host disconnects then attempt to reconnect the player to another hosted session automatically
0
Best Answer
-
Hello @ArrestedDeveloper ,
Starting the game as a client, you will have only one connection, the one made with the Game Server.
If you subscribe to the Disconnected event, you can check this:public override void Disconnected(BoltConnection connection) { if (BoltNetwork.Server.Equals(connection)) { BoltLog.Warn("Disconnected from the server"); } }
or using the BoltShutdownBegin callback, you can check the disconnectReason parameter:public override void BoltShutdownBegin(AddCallback registerDoneCallback, UdpConnectionDisconnectReason disconnectReason) { registerDoneCallback(() => { Debug.LogFormat("Shutdown Done with Reason: {0}", disconnectReason); SceneManager.LoadScene(0); }); }
In this last case, if you found the UdpConnectionDisconnectReason.Disconnected, so you have been disconnected from the server.1
Answers
-
Hello @ArrestedDeveloper ,
Starting the game as a client, you will have only one connection, the one made with the Game Server.
If you subscribe to the Disconnected event, you can check this:public override void Disconnected(BoltConnection connection) { if (BoltNetwork.Server.Equals(connection)) { BoltLog.Warn("Disconnected from the server"); } }
or using the BoltShutdownBegin callback, you can check the disconnectReason parameter:public override void BoltShutdownBegin(AddCallback registerDoneCallback, UdpConnectionDisconnectReason disconnectReason) { registerDoneCallback(() => { Debug.LogFormat("Shutdown Done with Reason: {0}", disconnectReason); SceneManager.LoadScene(0); }); }
In this last case, if you found the UdpConnectionDisconnectReason.Disconnected, so you have been disconnected from the server.1