|
6 | 6 | using MLAPI.Transports.LiteNetLib; |
7 | 7 | using MLAPI.Transports.PhotonRealtime; |
8 | 8 | using MLAPI.Transports.UNET; |
| 9 | +using Photon.Realtime; |
9 | 10 |
|
10 | 11 | namespace BossRoom.Client |
11 | 12 | { |
@@ -122,22 +123,38 @@ public static void StartClient(GameNetPortal portal, string ipaddress, int port) |
122 | 123 | /// Relay version of <see cref="StartClient"/>, see start client remarks for more information. |
123 | 124 | /// </remarks> |
124 | 125 | /// <param name="portal"> </param> |
125 | | - /// <param name="roomName">The room name of the host to connect to.</param> |
126 | | - public static void StartClientRelayMode(GameNetPortal portal, string roomName) |
| 126 | + /// <param name="roomKey">The room name of the host to connect to.</param> |
| 127 | + public static bool StartClientRelayMode(GameNetPortal portal, string roomKey, out string failMessage) |
127 | 128 | { |
| 129 | + var splits = roomKey.Split('_'); |
| 130 | + |
| 131 | + if (splits.Length != 2) |
| 132 | + { |
| 133 | + failMessage = "Malformatted Room Key!"; |
| 134 | + return false; |
| 135 | + } |
| 136 | + |
| 137 | + var region = splits[0]; |
| 138 | + var roomName = splits[1]; |
| 139 | + |
| 140 | + |
128 | 141 | var chosenTransport = NetworkManager.Singleton.gameObject.GetComponent<TransportPicker>().RelayTransport; |
129 | 142 | NetworkManager.Singleton.NetworkConfig.NetworkTransport = chosenTransport; |
130 | 143 |
|
131 | 144 | switch (chosenTransport) |
132 | 145 | { |
133 | 146 | case PhotonRealtimeTransport photonRealtimeTransport: |
134 | 147 | photonRealtimeTransport.RoomName = roomName; |
| 148 | + PhotonAppSettings.Instance.AppSettings.FixedRegion = region; |
135 | 149 | break; |
136 | 150 | default: |
137 | 151 | throw new Exception($"unhandled relay transport {chosenTransport.GetType()}"); |
138 | 152 | } |
139 | 153 |
|
140 | 154 | ConnectClient(portal); |
| 155 | + |
| 156 | + failMessage = String.Empty; |
| 157 | + return true; |
141 | 158 | } |
142 | 159 |
|
143 | 160 | private static void ConnectClient(GameNetPortal portal) |
|
0 commit comments