From 2d9ee5646c654ba2dcc48f8b974b5d78ea521a18 Mon Sep 17 00:00:00 2001 From: Robin Rolf Date: Wed, 18 Sep 2024 14:36:12 +0100 Subject: [PATCH] fix: Edgegap Lobby Error continues to Connecting (#3898) Missing return, oops. Also some minor readability cleanup --- .../EdgegapLobby/EdgegapLobbyKcpTransport.cs | 85 ++++++++++--------- 1 file changed, 44 insertions(+), 41 deletions(-) diff --git a/Assets/Mirror/Transports/Edgegap/EdgegapLobby/EdgegapLobbyKcpTransport.cs b/Assets/Mirror/Transports/Edgegap/EdgegapLobby/EdgegapLobbyKcpTransport.cs index 5eff64632..74945e1f6 100644 --- a/Assets/Mirror/Transports/Edgegap/EdgegapLobby/EdgegapLobbyKcpTransport.cs +++ b/Assets/Mirror/Transports/Edgegap/EdgegapLobby/EdgegapLobbyKcpTransport.cs @@ -206,63 +206,66 @@ private IEnumerator WaitForLobbyRelay(string lobbyId, bool forServer) Api.GetLobby(lobbyId, lobby => { waitingForResponse = false; - if (!string.IsNullOrEmpty(lobby.assignment.ip)) + if (string.IsNullOrEmpty(lobby.assignment.ip)) { - relayAddress = lobby.assignment.ip; - foreach (Lobby.Port aport in lobby.assignment.ports) + // no lobby deployed yet, have the outer loop retry + return; + } + relayAddress = lobby.assignment.ip; + foreach (Lobby.Port aport in lobby.assignment.ports) + { + if (aport.protocol == "UDP") { - if (aport.protocol == "UDP") + if (aport.name == "server") { - if (aport.name == "server") - { - relayGameServerPort = (ushort)aport.port; + relayGameServerPort = (ushort)aport.port; - } - else if (aport.name == "client") - { - relayGameClientPort = (ushort)aport.port; - } } - } - bool found = false; - foreach (Lobby.Player player in lobby.players) - { - if (player.id == _playerId) + else if (aport.name == "client") { - userId = player.authorization_token; - sessionId = lobby.assignment.authorization_token; - found = true; - break; + relayGameClientPort = (ushort)aport.port; } } - running = false; - if (!found) + } + bool found = false; + foreach (Lobby.Player player in lobby.players) + { + if (player.id == _playerId) { - string errorMsg = $"Couldn't find my player ({_playerId})"; - Debug.LogError(errorMsg); + userId = player.authorization_token; + sessionId = lobby.assignment.authorization_token; + found = true; + break; + } + } + running = false; + if (!found) + { + string errorMsg = $"Couldn't find my player ({_playerId})"; + Debug.LogError(errorMsg); - if (forServer) - { - _status = TransportStatus.Error; - OnServerError?.Invoke(0, TransportError.Unexpected, errorMsg); - ServerStop(); - } - else - { - _status = TransportStatus.Error; - OnClientError?.Invoke(TransportError.Unexpected, errorMsg); - ClientDisconnect(); - } - } - _status = TransportStatus.Connecting; if (forServer) { - base.ServerStart(); + _status = TransportStatus.Error; + OnServerError?.Invoke(0, TransportError.Unexpected, errorMsg); + ServerStop(); } else { - base.ClientConnect(""); + _status = TransportStatus.Error; + OnClientError?.Invoke(TransportError.Unexpected, errorMsg); + ClientDisconnect(); } + return; + } + _status = TransportStatus.Connecting; + if (forServer) + { + base.ServerStart(); + } + else + { + base.ClientConnect(""); } }, error => {