Skip to content

Commit 9fdc3fe

Browse files
committed
added UseEncryption and UseWebSockets for all connectiontypes for relay
1 parent e1df4c7 commit 9fdc3fe

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

Assets/Scripts/ConnectionManagement/ConnectionMethod.cs

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ class ConnectionMethodIP : ConnectionMethodBase
138138
-----END CERTIFICATE-----";
139139

140140
// this will be required for DTLS and WSS, removed for security purpose, saved locally
141-
private string PrivateKey1 =
142-
"";
141+
private string PrivateKey1 = "";
143142

144143
public ConnectionMethodIP(string ip, ushort port, ConnectionManager connectionManager, ProfileManager profileManager, string playerName)
145144
: base(connectionManager, profileManager, playerName)
@@ -266,6 +265,22 @@ public override async Task SetupClientConnectionAsync()
266265
if (ConnectionTypeDropdown.connectionType == "wss")
267266
{
268267
utp.UseWebSockets = true;
268+
utp.UseEncryption = true;
269+
}
270+
else if (ConnectionTypeDropdown.connectionType == "ws")
271+
{
272+
utp.UseWebSockets = true;
273+
utp.UseEncryption = false;
274+
}
275+
else if (ConnectionTypeDropdown.connectionType == "dtls")
276+
{
277+
utp.UseWebSockets = false;
278+
utp.UseEncryption = true;
279+
}
280+
else if (ConnectionTypeDropdown.connectionType == "udp")
281+
{
282+
utp.UseWebSockets = false;
283+
utp.UseEncryption = false;
269284
}
270285

271286
utp.SetRelayServerData(new RelayServerData(joinedAllocation, ConnectionTypeDropdown.connectionType));
@@ -316,6 +331,22 @@ public override async Task SetupHostConnectionAsync()
316331
if (ConnectionTypeDropdown.connectionType == "wss")
317332
{
318333
utp.UseWebSockets = true;
334+
utp.UseEncryption = true;
335+
}
336+
else if (ConnectionTypeDropdown.connectionType == "ws")
337+
{
338+
utp.UseWebSockets = true;
339+
utp.UseEncryption = false;
340+
}
341+
else if (ConnectionTypeDropdown.connectionType == "dtls")
342+
{
343+
utp.UseWebSockets = false;
344+
utp.UseEncryption = true;
345+
}
346+
else if (ConnectionTypeDropdown.connectionType == "udp")
347+
{
348+
utp.UseWebSockets = false;
349+
utp.UseEncryption = false;
319350
}
320351

321352
utp.SetRelayServerData(new RelayServerData(hostAllocation, ConnectionTypeDropdown.connectionType)); // This is with DTLS enabled for a secure connection

0 commit comments

Comments
 (0)