@@ -33,6 +33,7 @@ public class LobbyUIMediator : MonoBehaviour
3333 ISubscriber < ConnectStatus > m_ConnectStatusSubscriber ;
3434
3535 const string k_DefaultSessionName = "no-name" ;
36+ const int k_MaxPlayers = 8 ;
3637
3738 ISession m_Session ;
3839
@@ -93,6 +94,10 @@ public async void CreateSessionRequest(string sessionName, bool isPrivate)
9394
9495 m_ConnectionManager . StartHostSession ( m_LocalUser . DisplayName ) ;
9596
97+ var result = await m_MultiplayerServicesFacade . TryCreateSessionAsync ( sessionName , k_MaxPlayers , isPrivate ) ;
98+
99+ HandleSessionJoinResult ( result ) ;
100+
96101 UnblockUIAfterLoadingIsComplete ( ) ;
97102 }
98103
@@ -140,14 +145,7 @@ public async void JoinSessionWithCodeRequest(string sessionCode)
140145
141146 var result = await m_MultiplayerServicesFacade . TryJoinSessionAsync ( sessionCode , null ) ;
142147
143- if ( result . Success )
144- {
145- OnJoinedSession ( result . Session ) ;
146- }
147- else
148- {
149- UnblockUIAfterLoadingIsComplete ( ) ;
150- }
148+ HandleSessionJoinResult ( result ) ;
151149 }
152150
153151 public async void JoinSessionRequest ( ISessionInfo sessionInfo )
@@ -166,14 +164,7 @@ public async void JoinSessionRequest(ISessionInfo sessionInfo)
166164
167165 var result = await m_MultiplayerServicesFacade . TryJoinSessionAsync ( null , sessionInfo . Id ) ;
168166
169- if ( result . Success )
170- {
171- OnJoinedSession ( result . Session ) ;
172- }
173- else
174- {
175- UnblockUIAfterLoadingIsComplete ( ) ;
176- }
167+ HandleSessionJoinResult ( result ) ;
177168 }
178169
179170 public async void QuickJoinRequest ( )
@@ -192,6 +183,11 @@ public async void QuickJoinRequest()
192183
193184 var result = await m_MultiplayerServicesFacade . TryQuickJoinSessionAsync ( ) ;
194185
186+ HandleSessionJoinResult ( result ) ;
187+ }
188+
189+ void HandleSessionJoinResult ( ( bool Success , ISession Session ) result )
190+ {
195191 if ( result . Success )
196192 {
197193 OnJoinedSession ( result . Session ) ;
0 commit comments