Skip to content

Commit 301c71a

Browse files
committed
making sure we remove loading screen on timeout
1 parent 282f45d commit 301c71a

File tree

2 files changed

+11
-20
lines changed

2 files changed

+11
-20
lines changed

Assets/BossRoom/Scripts/Client/UI/Lobby/LobbyUIMediator.cs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public class LobbyUIMediator : MonoBehaviour
2929
NameGenerationData m_NameGenerationData;
3030
GameNetPortal m_GameNetPortal;
3131
ClientGameNetPortal m_ClientNetPortal;
32+
IDisposable m_Subscriptions;
3233

3334
const string k_DefaultLobbyName = "no-name";
3435

@@ -39,6 +40,7 @@ void InjectDependenciesAndInitialize(
3940
LocalLobby localLobby,
4041
NameGenerationData nameGenerationData,
4142
GameNetPortal gameNetPortal,
43+
ISubscriber<ConnectStatus> connectStatusSub,
4244
ClientGameNetPortal clientGameNetPortal
4345
)
4446
{
@@ -51,17 +53,22 @@ ClientGameNetPortal clientGameNetPortal
5153

5254
RegenerateName();
5355

54-
m_ClientNetPortal.NetworkTimedOut += OnNetworkTimeout;
56+
m_Subscriptions = connectStatusSub.Subscribe(OnConnectStatus);
5557
}
5658

57-
void OnDestroy()
59+
void OnConnectStatus(ConnectStatus status)
5860
{
59-
if (m_ClientNetPortal != null)
61+
if (status == ConnectStatus.GenericDisconnect)
6062
{
61-
m_ClientNetPortal.NetworkTimedOut -= OnNetworkTimeout;
63+
UnblockUIAfterLoadingIsComplete();
6264
}
6365
}
6466

67+
void OnDestroy()
68+
{
69+
m_Subscriptions.Dispose();
70+
}
71+
6572
//Lobby and Relay calls done from UI
6673

6774
public void CreateLobbyRequest(string lobbyName, bool isPrivate, int maxPlayers, OnlineMode onlineMode)
@@ -236,15 +243,5 @@ void UnblockUIAfterLoadingIsComplete()
236243
m_LoadingSpinner.SetActive(false);
237244
}
238245
}
239-
240-
/// <summary>
241-
/// Invoked when the client sent a connection request to the server and didn't hear back at all.
242-
/// This should create a UI letting the player know that something went wrong and to try again
243-
/// </summary>
244-
void OnNetworkTimeout()
245-
{
246-
m_LobbyServiceFacade.EndTracking();
247-
UnblockUIAfterLoadingIsComplete();
248-
}
249246
}
250247
}

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ public class ClientGameNetPortal : MonoBehaviour
3535
private const int k_TimeoutDuration = 10;
3636
const int k_NbReconnectAttempts = 1;
3737

38-
/// <summary>
39-
/// This event fires when the client sent out a request to start the client, but failed to hear back after an allotted amount of
40-
/// time from the host.
41-
/// </summary>
42-
public event Action NetworkTimedOut;
43-
4438
ApplicationController m_ApplicationController;
4539
LobbyServiceFacade m_LobbyServiceFacade;
4640
IPublisher<ConnectStatus> m_ConnectStatusPub;

0 commit comments

Comments
 (0)