Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions Assets/BossRoom/Scripts/Client/Net/ClientGameNetPortal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,21 @@ private void OnConnectFinished(ConnectStatus status)

private void OnDisconnectOrTimeout(ulong clientID)
{
//On a client disconnect we want to take them back to the main menu.
//We have to check here in SceneManager if our active scene is the main menu, as if it is, it means we timed out rather than a raw disconnect;
if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name != "MainMenu")
if(clientID == MLAPI.NetworkManager.Singleton.LocalClientId )
{
// we're not at the main menu, so we obviously had a connection before... thus, we aren't in a timeout scenario.
// Just shut down networking and switch back to main menu.
MLAPI.NetworkManager.Singleton.Shutdown();
SceneManager.LoadScene("MainMenu");
}
else
{
NetworkTimedOut?.Invoke();
//On a client disconnect we want to take them back to the main menu.
//We have to check here in SceneManager if our active scene is the main menu, as if it is, it means we timed out rather than a raw disconnect;
if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name != "MainMenu")
{
// we're not at the main menu, so we obviously had a connection before... thus, we aren't in a timeout scenario.
// Just shut down networking and switch back to main menu.
MLAPI.NetworkManager.Singleton.Shutdown();
SceneManager.LoadScene("MainMenu");
}
else
{
NetworkTimedOut?.Invoke();
}
}
}

Expand Down