@@ -29,6 +29,7 @@ public class LobbyUIMediator : MonoBehaviour
29
29
NameGenerationData m_NameGenerationData ;
30
30
GameNetPortal m_GameNetPortal ;
31
31
ClientGameNetPortal m_ClientNetPortal ;
32
+ IDisposable m_Subscriptions ;
32
33
33
34
const string k_DefaultLobbyName = "no-name" ;
34
35
@@ -39,6 +40,7 @@ void InjectDependenciesAndInitialize(
39
40
LocalLobby localLobby ,
40
41
NameGenerationData nameGenerationData ,
41
42
GameNetPortal gameNetPortal ,
43
+ ISubscriber < ConnectStatus > connectStatusSub ,
42
44
ClientGameNetPortal clientGameNetPortal
43
45
)
44
46
{
@@ -51,17 +53,22 @@ ClientGameNetPortal clientGameNetPortal
51
53
52
54
RegenerateName ( ) ;
53
55
54
- m_ClientNetPortal . NetworkTimedOut += OnNetworkTimeout ;
56
+ m_Subscriptions = connectStatusSub . Subscribe ( OnConnectStatus ) ;
55
57
}
56
58
57
- void OnDestroy ( )
59
+ void OnConnectStatus ( ConnectStatus status )
58
60
{
59
- if ( m_ClientNetPortal != null )
61
+ if ( status == ConnectStatus . GenericDisconnect )
60
62
{
61
- m_ClientNetPortal . NetworkTimedOut -= OnNetworkTimeout ;
63
+ UnblockUIAfterLoadingIsComplete ( ) ;
62
64
}
63
65
}
64
66
67
+ void OnDestroy ( )
68
+ {
69
+ m_Subscriptions . Dispose ( ) ;
70
+ }
71
+
65
72
//Lobby and Relay calls done from UI
66
73
67
74
public void CreateLobbyRequest ( string lobbyName , bool isPrivate , int maxPlayers , OnlineMode onlineMode )
@@ -236,15 +243,5 @@ void UnblockUIAfterLoadingIsComplete()
236
243
m_LoadingSpinner . SetActive ( false ) ;
237
244
}
238
245
}
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
- }
249
246
}
250
247
}
0 commit comments