BoltEngine / Bolt-Tracker

New issue tracker for Photon Bolt
10 stars 2 forks source link

How to detect a disconnnected user in the updated Bolt Engine? Can you explain with examples? #175

Closed yessGlory17 closed 4 years ago

yessGlory17 commented 4 years ago

How to detect a disconnnected user in the updated Bolt Engine? Can you explain with examples?

unknown

Bolt Engine crashes when the user loses internet connection.

ramonmelo commented 4 years ago

Hello @yessGlory17 ,

Which Bolt version are you using? (the original issue template help us the know better your scenario from start)

By just adding this snippet to any GlobalEventListener that is currently running on the Scene, you should be able to catch the Timeout error and load the Scene with Index 0. This works for both the client and the server;

public override void BoltShutdownBegin(AddCallback registerDoneCallback, UdpConnectionDisconnectReason disconnectReason)
{
    registerDoneCallback(() =>
    {
        Debug.LogFormat("Shutdown Done with Reason: {0}", disconnectReason);
        SceneManager.LoadScene(0);
    });
}

Which errors do you see? Can you send us the logs?

Also, in order to detect that a remote peer has disconnected just override the Disconnected on any GlobalEventListener on your scene:

public override void Disconnected(BoltConnection connection)
{
    Debug.LogFormat("{0} disconnected", connection.RemoteEndPoint);
}

-- Ramon Melo Photon Bolt Team