Skip to content

Commit

Permalink
fix: create session logic
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianStoll committed Oct 25, 2024
1 parent f23621f commit 9416fb2
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions Assets/Scripts/Gameplay/UI/Lobby/LobbyUIMediator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class LobbyUIMediator : MonoBehaviour
ISubscriber<ConnectStatus> m_ConnectStatusSubscriber;

const string k_DefaultSessionName = "no-name";
const int k_MaxPlayers = 8;

ISession m_Session;

Expand Down Expand Up @@ -93,6 +94,10 @@ public async void CreateSessionRequest(string sessionName, bool isPrivate)

m_ConnectionManager.StartHostSession(m_LocalUser.DisplayName);

var result = await m_MultiplayerServicesFacade.TryCreateSessionAsync(sessionName, k_MaxPlayers, isPrivate);

HandleSessionJoinResult(result);

UnblockUIAfterLoadingIsComplete();
}

Expand Down Expand Up @@ -140,14 +145,7 @@ public async void JoinSessionWithCodeRequest(string sessionCode)

var result = await m_MultiplayerServicesFacade.TryJoinSessionAsync(sessionCode, null);

if (result.Success)
{
OnJoinedSession(result.Session);
}
else
{
UnblockUIAfterLoadingIsComplete();
}
HandleSessionJoinResult(result);
}

public async void JoinSessionRequest(ISessionInfo sessionInfo)
Expand All @@ -166,14 +164,7 @@ public async void JoinSessionRequest(ISessionInfo sessionInfo)

var result = await m_MultiplayerServicesFacade.TryJoinSessionAsync(null, sessionInfo.Id);

if (result.Success)
{
OnJoinedSession(result.Session);
}
else
{
UnblockUIAfterLoadingIsComplete();
}
HandleSessionJoinResult(result);
}

public async void QuickJoinRequest()
Expand All @@ -192,6 +183,11 @@ public async void QuickJoinRequest()

var result = await m_MultiplayerServicesFacade.TryQuickJoinSessionAsync();

HandleSessionJoinResult(result);
}

void HandleSessionJoinResult((bool Success, ISession Session) result)
{
if (result.Success)
{
OnJoinedSession(result.Session);
Expand Down

0 comments on commit 9416fb2

Please sign in to comment.