您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

31 行
1.3 KiB

using System;
using Unity.Services.Lobbies;
namespace LobbyRelaySample.lobby
{
public class AsyncRequestLobby : AsyncRequest
{
private static AsyncRequestLobby s_instance;
public static AsyncRequestLobby Instance
{
get
{ if (s_instance == null)
s_instance = new AsyncRequestLobby();
return s_instance;
}
}
/// <summary>
/// The Lobby service will wrap HTTP errors in LobbyServiceExceptions. We can filter on LobbyServiceException.Reason for custom behavior.
/// </summary>
protected override void ParseServiceException(Exception e)
{
if (!(e is LobbyServiceException))
return;
var lobbyEx = e as LobbyServiceException;
if (lobbyEx.Reason == LobbyExceptionReason.RateLimited) // We have other ways of preventing players from hitting the rate limit, so the developer-facing 429 error is sufficient here.
return;
Locator.Get.Messenger.OnReceiveMessage(MessageType.DisplayErrorPopup, $"Lobby Error: {lobbyEx.Message} ({lobbyEx.InnerException.Message})"); // Lobby error type, then HTTP error type.
}
}
}