Skip to content

Commit 2973861

Browse files
committed
reverted unneeded change
1 parent 788eb23 commit 2973861

File tree

1 file changed

+20
-26
lines changed

1 file changed

+20
-26
lines changed

Assets/BossRoom/Scripts/Shared/Net/ConnectionManagement/ClientGameNetPortal.cs

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ public class ClientGameNetPortal : MonoBehaviour
1717
public static ClientGameNetPortal Instance;
1818
private GameNetPortal m_Portal;
1919

20-
string m_JoinCode;
21-
2220
/// <summary>
2321
/// If a disconnect occurred this will be populated with any contextual information that was available to explain why.
2422
/// </summary>
@@ -178,42 +176,38 @@ public void StartClient(string ipaddress, int port)
178176
throw new ArgumentOutOfRangeException(nameof(chosenTransport));
179177
}
180178

181-
ConnectClient(null);
179+
ConnectClient();
182180
}
183181

184-
public void StartClientUnityRelayModeAsync(string joinCode, Action<string> onFailure)
182+
public async void StartClientUnityRelayModeAsync(string joinCode, Action<string> onFailure)
185183
{
186184
m_Portal.OnlineMode = OnlineMode.UnityRelay;
187-
m_JoinCode = joinCode;
188-
var utp = NetworkManager.Singleton.gameObject.GetComponent<TransportPicker>().UnityRelayTransport;
185+
var utp = (UnityTransport)NetworkManager.Singleton.gameObject.GetComponent<TransportPicker>().UnityRelayTransport;
189186
NetworkManager.Singleton.NetworkConfig.NetworkTransport = utp;
190187

191188
Debug.Log($"Setting Unity Relay client with join code {joinCode}");
192189

193-
ConnectClient(onFailure);
194-
}
190+
try
191+
{
192+
var clientRelayUtilityTask = UnityRelayUtilities.JoinRelayServerFromJoinCode(joinCode);
193+
await clientRelayUtilityTask;
194+
var (ipv4Address, port, allocationIdBytes, connectionData, hostConnectionData, key) = clientRelayUtilityTask.Result;
195195

196-
async void ConnectClient(Action<string> onFailure)
197-
{
198-
if (m_Portal.OnlineMode == OnlineMode.UnityRelay)
196+
m_LobbyServiceFacade.UpdatePlayerRelayInfoAsync(allocationIdBytes.ToString(), joinCode, null, null);
197+
utp.SetClientRelayData(ipv4Address, port, allocationIdBytes, key, connectionData, hostConnectionData, isSecure: true);
198+
}
199+
catch (Exception e)
199200
{
200-
try
201-
{
202-
var clientRelayUtilityTask = UnityRelayUtilities.JoinRelayServerFromJoinCode(m_JoinCode);
203-
await clientRelayUtilityTask;
204-
var (ipv4Address, port, allocationIdBytes, connectionData, hostConnectionData, key) = clientRelayUtilityTask.Result;
201+
onFailure?.Invoke(e.Message);
202+
return;//not re-throwing, but still not allowing to connect
203+
}
205204

206-
m_LobbyServiceFacade.UpdatePlayerRelayInfoAsync(allocationIdBytes.ToString(), m_JoinCode, null, null);
207-
var utp = (UnityTransport) NetworkManager.Singleton.NetworkConfig.NetworkTransport;
208-
utp.SetClientRelayData(ipv4Address, port, allocationIdBytes, key, connectionData, hostConnectionData, isSecure: true);
209-
}
210-
catch (Exception e)
211-
{
212-
onFailure?.Invoke(e.Message);
213-
return;//not re-throwing, but still not allowing to connect
214-
}
215205

216-
}
206+
ConnectClient();
207+
}
208+
209+
void ConnectClient()
210+
{
217211

218212
var payload = JsonUtility.ToJson(new ConnectionPayload()
219213
{

0 commit comments

Comments
 (0)