Skip to content

cherrypick fix: Adding handling of host disconnect (#486) #509

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 8, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ private void OnDisconnectReasonReceived(ConnectStatus status)

private void OnDisconnectOrTimeout(ulong clientID)
{
// Only handle client disconnect
if (!NetworkManager.Singleton.IsHost)
// This is also called on the Host when a different client disconnects. To make sure we only handle our own disconnection, verify that we are either
// not a host (in which case we know this is about us) or that the clientID is the same as ours if we are the host.
if (!NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsHost && NetworkManager.Singleton.LocalClientId == 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;
Expand Down