Skip to content

Commit a96aa5c

Browse files
authored
feat: display popup when failing to connect to full lobby (#525) (#566)
(cherry picked from commit 18566e3)
1 parent 5356e3c commit a96aa5c

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

Assets/BossRoom/Scripts/Client/UI/UnityServicesUIHandler.cs

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,7 @@ void ServiceErrorHandler(UnityServiceErrorMessage error)
2929
{
3030
case UnityServiceErrorMessage.Service.Lobby:
3131
{
32-
if ((error.OriginalException is LobbyServiceException {Reason: LobbyExceptionReason.LobbyConflict}))
33-
{
34-
// LobbyConflict can have multiple causes. Let's add other solutions here if there's other situations that arise for this.
35-
errorMessage += "\nSee logs for possible causes and solution.";
36-
Debug.LogError($"Got service error {error.Message} with LobbyConflict. Possible conflict cause: Trying to play with two builds on the " +
37-
$"same machine. Please use command line arg '{ProfileManager.AuthProfileCommandLineArg} someName' to set a different auth profile.\n");
38-
}
39-
PopupPanel.ShowPopupPanel("Service error", errorMessage);
32+
HandleLobbyError(error);
4033
break;
4134
}
4235
case UnityServiceErrorMessage.Service.Authentication:
@@ -48,12 +41,35 @@ void ServiceErrorHandler(UnityServiceErrorMessage error)
4841
}
4942
default:
5043
{
51-
PopupPanel.ShowPopupPanel("Service error: "+error.Title, errorMessage);
44+
PopupPanel.ShowPopupPanel("Service error: " + error.Title, errorMessage);
5245
break;
5346
}
5447
}
5548
}
5649

50+
void HandleLobbyError(UnityServiceErrorMessage error)
51+
{
52+
var errorMessage = error.Message;
53+
switch (((LobbyServiceException)error.OriginalException).Reason)
54+
{
55+
case LobbyExceptionReason.LobbyConflict:
56+
{
57+
errorMessage += "\nSee logs for possible causes and solution.";
58+
Debug.LogError($"Got service error {error.Message} with LobbyConflict. Possible conflict cause: Trying to play with two builds on the " +
59+
$"same machine. Please use command line arg '{ProfileManager.AuthProfileCommandLineArg} someName' to set a different auth profile.\n");
60+
break;
61+
}
62+
case LobbyExceptionReason.LobbyFull:
63+
{
64+
PopupPanel.ShowPopupPanel("Failed to join lobby", "Lobby is full and can't accept more players");
65+
// Returning out of the function because we replace default popup panel with this.
66+
return;
67+
}
68+
}
69+
70+
PopupPanel.ShowPopupPanel("Service error: " + error.Title, errorMessage);
71+
}
72+
5773
void OnDestroy()
5874
{
5975
m_Subscriptions.Dispose();

0 commit comments

Comments
 (0)