Skip to content

Commit c04832c

Browse files
committed
Adding handling of host disconnect (#486)
(cherry picked from commit 89f9918)
1 parent d26d8e6 commit c04832c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Assets/BossRoom/Scripts/Shared/Net/ConnectionManagement/ClientGameNetPortal.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@ private void OnDisconnectReasonReceived(ConnectStatus status)
120120

121121
private void OnDisconnectOrTimeout(ulong clientID)
122122
{
123-
// Only handle client disconnect
124-
if (!NetworkManager.Singleton.IsHost)
123+
// 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
124+
// 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.
125+
if (!NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsHost && NetworkManager.Singleton.LocalClientId == clientID)
125126
{
126127
//On a client disconnect we want to take them back to the main menu.
127128
//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;

0 commit comments

Comments
 (0)