浏览代码

Adding in Relay exception handling, though I haven't yet found a way to test it out with more than a couple error types. It seems to work just fine.

/main/staging/error_codes_to_exceptions
nathaniel.buck@unity3d.com 3 年前
当前提交
831ba275
共有 3 个文件被更改,包括 14 次插入3 次删除
  1. 2
      Assets/Scripts/Lobby/AsyncRequestLobby.cs
  2. 11
      Assets/Scripts/Relay/AsyncRequestRelay.cs
  3. 4
      Assets/Scripts/Relay/RelayUtpClient.cs

2
Assets/Scripts/Lobby/AsyncRequestLobby.cs


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, $"Error: {lobbyEx.Message} ({lobbyEx.InnerException.Message})"); // Lobby error type, then HTTP error type.
Locator.Get.Messenger.OnReceiveMessage(MessageType.DisplayErrorPopup, $"Lobby Error: {lobbyEx.Message} ({lobbyEx.InnerException.Message})"); // Lobby error type, then HTTP error type.
}
}
}

11
Assets/Scripts/Relay/AsyncRequestRelay.cs


}
}
/// <summary>
/// The Relay service will wrap HTTP errors in RelayServiceExceptions. We can filter on RelayServiceException.Reason for custom behavior.
/// </summary>
// TODO: Implement
if (!(e is RelayServiceException))
return;
var relayEx = e as RelayServiceException;
if (relayEx.Reason == RelayExceptionReason.Unknown)
Locator.Get.Messenger.OnReceiveMessage(MessageType.DisplayErrorPopup, "Relay Error: Relay service had an unknown error.");
else
Locator.Get.Messenger.OnReceiveMessage(MessageType.DisplayErrorPopup, $"Relay Error: {relayEx.Message}");
}
}
}

4
Assets/Scripts/Relay/RelayUtpClient.cs


protected virtual void ProcessDisconnectEvent(NetworkConnection conn, DataStreamReader strm)
{
// The host disconnected, and Relay does not support host migration. So, all clients should disconnect.
Debug.LogError("Host disconnected! Leaving the lobby.");
string msg = "Host disconnected! Leaving the lobby.";
Debug.LogError(msg);
Locator.Get.Messenger.OnReceiveMessage(MessageType.DisplayErrorPopup, msg);
Leave();
Locator.Get.Messenger.OnReceiveMessage(MessageType.ChangeGameState, GameState.JoinMenu);
}

正在加载...
取消
保存