Skip to content

Commit 7fef46c

Browse files
committed
reordered reconnect flow to make sure netmanager is shut down before loading main menu
1 parent c05ee7c commit 7fef46c

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -182,17 +182,14 @@ private IEnumerator TryToReconnect()
182182
nbTries++;
183183
}
184184

185-
if (!NetworkManager.Singleton.IsConnectedClient)
185+
// If the coroutine has not been stopped before this, it means we failed to connect during all attempts
186+
Debug.Log("All tries failed, returning to main menu");
187+
NetworkManager.Singleton.Shutdown();
188+
SceneLoaderWrapper.Instance.LoadScene("MainMenu");
189+
if (!DisconnectReason.HasTransitionReason)
186190
{
187-
Debug.Log("All tries failed, returning to main menu");
188-
SceneLoaderWrapper.Instance.LoadScene("MainMenu");
189-
if (!DisconnectReason.HasTransitionReason)
190-
{
191-
DisconnectReason.SetDisconnectReason(ConnectStatus.GenericDisconnect);
192-
}
193-
191+
DisconnectReason.SetDisconnectReason(ConnectStatus.GenericDisconnect);
194192
}
195-
NetworkManager.Singleton.Shutdown();
196193
m_TryToReconnectCoroutine = null;
197194
m_ConnectStatusPub.Publish(DisconnectReason.Reason);
198195
}

0 commit comments

Comments
 (0)