Skip to content

Commit

Permalink
Adding handling of host disconnect (#486)
Browse files Browse the repository at this point in the history
  • Loading branch information
LPLafontaineB committed Mar 4, 2022
1 parent 6c215be commit 89f9918
Showing 1 changed file with 3 additions and 2 deletions.
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

0 comments on commit 89f9918

Please sign in to comment.