Skip to content

feat: display popup when failing to connect to full lobby #525

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 25 additions & 9 deletions Assets/BossRoom/Scripts/Client/UI/UnityServicesUIHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,7 @@ void ServiceErrorHandler(UnityServiceErrorMessage error)
{
case UnityServiceErrorMessage.Service.Lobby:
{
if ((error.OriginalException is LobbyServiceException {Reason: LobbyExceptionReason.LobbyConflict}))
{
// LobbyConflict can have multiple causes. Let's add other solutions here if there's other situations that arise for this.
errorMessage += "\nSee logs for possible causes and solution.";
Debug.LogError($"Got service error {error.Message} with LobbyConflict. Possible conflict cause: Trying to play with two builds on the " +
$"same machine. Please use command line arg '{ProfileManager.AuthProfileCommandLineArg} someName' to set a different auth profile.\n");
}
PopupPanel.ShowPopupPanel("Service error", errorMessage);
HandleLobbyError(error);
break;
}
case UnityServiceErrorMessage.Service.Authentication:
Expand All @@ -48,12 +41,35 @@ void ServiceErrorHandler(UnityServiceErrorMessage error)
}
default:
{
PopupPanel.ShowPopupPanel("Service error: "+error.Title, errorMessage);
PopupPanel.ShowPopupPanel("Service error: " + error.Title, errorMessage);
break;
}
}
}

void HandleLobbyError(UnityServiceErrorMessage error)
{
var errorMessage = error.Message;
switch (((LobbyServiceException)error.OriginalException).Reason)
{
case LobbyExceptionReason.LobbyConflict:
{
errorMessage += "\nSee logs for possible causes and solution.";
Debug.LogError($"Got service error {error.Message} with LobbyConflict. Possible conflict cause: Trying to play with two builds on the " +
$"same machine. Please use command line arg '{ProfileManager.AuthProfileCommandLineArg} someName' to set a different auth profile.\n");
break;
}
case LobbyExceptionReason.LobbyFull:
{
PopupPanel.ShowPopupPanel("Failed to join lobby", "Lobby is full and can't accept more players");
// Returning out of the function because we replace default popup panel with this.
return;
}
}

PopupPanel.ShowPopupPanel("Service error: " + error.Title, errorMessage);
}

void OnDestroy()
{
m_Subscriptions.Dispose();
Expand Down