1
1
using System ;
2
+ using System . Linq ;
2
3
using System . Threading . Tasks ;
3
4
using UnityEngine ;
4
5
using Unity . Services . Relay ;
@@ -8,6 +9,7 @@ namespace Unity.Multiplayer.Samples.BossRoom
8
9
{
9
10
public static class UnityRelayUtilities
10
11
{
12
+ private const string kDtlsConnType = "dtls" ;
11
13
12
14
public static async
13
15
Task < ( string ipv4address , ushort port , byte [ ] allocationIdBytes , byte [ ] connectionData , byte [ ] key , string
@@ -37,7 +39,8 @@ public static async
37
39
throw new Exception ( $ "Creating join code request has failed: \n { exception . Message } ") ;
38
40
}
39
41
40
- return ( allocation . RelayServer . IpV4 , ( ushort ) allocation . RelayServer . Port , allocation . AllocationIdBytes ,
42
+ var dtlsEndpoint = allocation . ServerEndpoints . First ( e => e . ConnectionType == kDtlsConnType ) ;
43
+ return ( dtlsEndpoint . Host , ( ushort ) dtlsEndpoint . Port , allocation . AllocationIdBytes ,
41
44
allocation . ConnectionData , allocation . Key , joinCode ) ;
42
45
}
43
46
@@ -59,7 +62,8 @@ public static async
59
62
Debug . Log ( $ "host: { allocation . HostConnectionData [ 0 ] } { allocation . HostConnectionData [ 1 ] } ") ;
60
63
Debug . Log ( $ "client: { allocation . AllocationId } ") ;
61
64
62
- return ( allocation . RelayServer . IpV4 , ( ushort ) allocation . RelayServer . Port , allocation . AllocationIdBytes ,
65
+ var dtlsEndpoint = allocation . ServerEndpoints . First ( e => e . ConnectionType == kDtlsConnType ) ;
66
+ return ( dtlsEndpoint . Host , ( ushort ) dtlsEndpoint . Port , allocation . AllocationIdBytes ,
63
67
allocation . ConnectionData , allocation . HostConnectionData , allocation . Key ) ;
64
68
}
65
69
}
0 commit comments