/// <summary> /// Callback that happens when a <see cref="T:NetworkMatch.JoinMatch"/> request has been processed on the /// server. /// </summary> /// <param name="success">Indicates if the request succeeded.</param> /// <param name="extendedInfo">A text description for the error if success is false.</param> /// <param name="matchInfo">The info for the newly joined match.</param> private void _OnMatchJoined(bool success, string extendedInfo, MatchInfo matchInfo) { if (!success) { SnackbarText.text = "Could not join to match: " + extendedInfo; return; } string ipAddress = ""; int port = 0; bool parameterRecovered = true; try { string connectionURL = m_Manager.matchName.Substring(m_Manager.matchName.IndexOf('@') + 1); ipAddress = connectionURL.Substring(0, connectionURL.IndexOf(':')); port = Convert.ToInt32(connectionURL.Substring(connectionURL.IndexOf(':') + 1)); } catch (Exception) { parameterRecovered = false; } if (parameterRecovered == false) { return; } // Init connected element UI ClientConnectedUI.HideUIElement(); SetTransportSettings(); CustomRelayedTransport customRelayedTransport = GetComponent <CustomRelayedTransport>(); customRelayedTransport.ConnectAddress = ipAddress; customRelayedTransport.ConnectPort = port; // Settings client IP address NetworkingManager.Singleton.StartClient(); ShowConnectionInformation(); m_CurrentRoomNumber = _GeetRoomNumberFromNetworkId(matchInfo.networkId); _ChangeLobbyUIVisibility(false); SnackbarText.text = "Point the same plane of hosting smartphone and wait..."; CurrentRoomLabel.GetComponentInChildren <Text>().text = "Room: " + m_CurrentRoomNumber; }
private void SetTransportSettings() { // Setting the custom transport that change parameter to adapt settings to 4G network CustomRelayedTransport customRelayedTransport = GetComponent <CustomRelayedTransport>(); if (Settings.Settings.Instance.Type == Settings.Settings.ConnectionType.MLAPI_Relay) { // Set dynamically Relay Server address customRelayedTransport.UseMLAPIRelay = true; customRelayedTransport.MLAPIRelayAddress = Settings.Settings.Instance.RelayAddress; customRelayedTransport.MLAPIRelayPort = 8888; } else { // Unused customRelayedTransport.UseMLAPIRelay = false; } }