Skip to content

Commit ea48b1f

Browse files
authored
Update Relay SDK version (#909)
* update to relay sdk v0.0.1-preview.5 * remove workarounds - use byte array representation of allocation id - connection data truncation is not longer needed - set default relay endpoint as production * updated auth to v0.5.0 - updated core and authentication versions - updated relay version (compatible with latest core) - updated authentication calls
1 parent 75133d4 commit ea48b1f

File tree

6 files changed

+27
-63
lines changed

6 files changed

+27
-63
lines changed

com.unity.multiplayer.transport.utp/Runtime/UTPTransport.cs

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private enum State
4040
[SerializeField] private string m_ServerAddress = "127.0.0.1";
4141
[SerializeField] private ushort m_ServerPort = 7777;
4242
[SerializeField] private int m_RelayMaxPlayers = 10;
43-
[SerializeField] private string m_RelayServer = "https://relay-allocations-stg.cloud.unity3d.com";
43+
[SerializeField] private string m_RelayServer = "https://relay-allocations.cloud.unity3d.com";
4444

4545
private State m_State = State.Disconnected;
4646
private NetworkDriver m_Driver;
@@ -95,20 +95,10 @@ private IEnumerator ClientBindAndConnect(SocketTask task)
9595
var allocation = joinTask.Result.Result.Data.Allocation;
9696

9797
serverEndpoint = NetworkEndPoint.Parse(allocation.RelayServer.IpV4, (ushort)allocation.RelayServer.Port);
98-
#if RELAY_BIGENDIAN
99-
// TODO: endianess of Relay server does not match
100-
var allocationIdArray = allocation.AllocationId.ToByteArray();
101-
Array.Reverse(allocationIdArray, 0, 4);
102-
Array.Reverse(allocationIdArray, 4, 2);
103-
Array.Reverse(allocationIdArray, 6, 2);
104-
var allocationId = RelayAllocationId.FromByteArray(allocationIdArray);
105-
#else
106-
var allocationId = RelayAllocationId.FromByteArray(allocation.AllocationId.ToByteArray());
107-
#endif
108-
109-
// TODO: workaround for receiving 271 bytes in connection data
110-
var connectionData = RelayConnectionData.FromByteArray(allocation.ConnectionData.Take(255).ToArray());
111-
var hostConnectionData = RelayConnectionData.FromByteArray(allocation.HostConnectionData.Take(255).ToArray());
98+
var allocationId = RelayAllocationId.FromByteArray(allocation.AllocationIdBytes);
99+
100+
var connectionData = RelayConnectionData.FromByteArray(allocation.ConnectionData);
101+
var hostConnectionData = RelayConnectionData.FromByteArray(allocation.HostConnectionData);
112102
var key = RelayHMACKey.FromByteArray(allocation.Key);
113103

114104
Debug.Log($"client: {allocation.ConnectionData[0]} {allocation.ConnectionData[1]}");
@@ -240,17 +230,9 @@ private IEnumerator StartRelayServer(SocketTask task)
240230

241231
var serverEndpoint = NetworkEndPoint.Parse(allocation.RelayServer.IpV4, (ushort)allocation.RelayServer.Port);
242232
// Debug.Log($"Relay Server endpoint: {allocation.RelayServer.IpV4}:{(ushort)allocation.RelayServer.Port}");
243-
#if RELAY_BIGENDIAN
244-
var allocationIdArray = allocation.AllocationId.ToByteArray();
245-
Array.Reverse(allocationIdArray, 0, 4);
246-
Array.Reverse(allocationIdArray, 4, 2);
247-
Array.Reverse(allocationIdArray, 6, 2);
248-
var allocationId = RelayAllocationId.FromByteArray(allocationIdArray);
249-
#else
250-
var allocationId = RelayAllocationId.FromByteArray(allocation.AllocationId.ToByteArray());
251-
#endif
252-
// TODO: connectionData should be 255 bytes, but we are getting 16 extra bytes
253-
var connectionData = RelayConnectionData.FromByteArray(allocation.ConnectionData.Take(255).ToArray());
233+
var allocationId = RelayAllocationId.FromByteArray(allocation.AllocationIdBytes);
234+
235+
var connectionData = RelayConnectionData.FromByteArray(allocation.ConnectionData);
254236
var key = RelayHMACKey.FromByteArray(allocation.Key);
255237

256238

@@ -385,7 +367,7 @@ public override void Init()
385367
m_MessageBuffer = new byte[m_MessageBufferSize];
386368
#if ENABLE_RELAY_SERVICE
387369
if (m_ProtocolType == ProtocolType.RelayUnityTransport) {
388-
Unity.Services.Relay.Configuration.BasePath = m_RelayServer;
370+
Unity.Services.Relay.RelayService.Configuration.BasePath = m_RelayServer;
389371
UnityServices.Initialize();
390372
}
391373
#endif

testproject/Assets/Scripts/ConnectionModeScript.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ private void Start()
6868
if (NetworkManager.Singleton.GetComponent<UTPTransport>().Protocol == UTPTransport.ProtocolType.RelayUnityTransport)
6969
{
7070
m_JoinCodeInput.SetActive(true);
71-
m_ConnectionModeButtons.SetActive(false || Authentication.IsSignedIn);
72-
m_AuthenticationButtons.SetActive(NetworkManager.Singleton && !NetworkManager.Singleton.IsListening && !Authentication.IsSignedIn);
71+
m_ConnectionModeButtons.SetActive(false || AuthenticationService.Instance.IsSignedIn);
72+
m_AuthenticationButtons.SetActive(NetworkManager.Singleton && !NetworkManager.Singleton.IsListening && !AuthenticationService.Instance.IsSignedIn);
7373
}
7474
else
7575
#endif
@@ -128,10 +128,10 @@ public async void OnSignIn()
128128
{
129129
#if ENABLE_RELAY_SERVICE
130130
await UnityServices.Initialize();
131-
await Authentication.SignInAnonymously();
132-
Debug.Log($"Logging in with PlayerID {Authentication.PlayerId}");
131+
await AuthenticationService.Instance.SignInAnonymouslyAsync();
132+
Debug.Log($"Logging in with PlayerID {AuthenticationService.Instance.PlayerId}");
133133

134-
if (Authentication.IsSignedIn)
134+
if (AuthenticationService.Instance.IsSignedIn)
135135
{
136136
m_ConnectionModeButtons.SetActive(true);
137137
m_AuthenticationButtons.SetActive(false);

testproject/Assets/Scripts/UIController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ public async void OnSignIn()
5454
#if ENABLE_RELAY_SERVICE
5555
await UnityServices.Initialize();
5656
Debug.Log("OnSignIn");
57-
await Authentication.SignInAnonymously();
58-
Debug.Log($"Logging in with PlayerID {Authentication.PlayerId}");
57+
await AuthenticationService.Instance.SignInAnonymouslyAsync();
58+
Debug.Log($"Logging in with PlayerID {AuthenticationService.Instance.PlayerId}");
5959

60-
if (Authentication.IsSignedIn) {
60+
if (AuthenticationService.Instance.IsSignedIn) {
6161
ButtonsRoot.SetActive(true);
6262
JoinCode.SetActive(true);
6363
AuthButton.SetActive(false);

testproject/Packages/manifest.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
"com.unity.multiplayer.mlapi": "file:../../com.unity.multiplayer.mlapi",
88
"com.unity.multiplayer.transport.utp": "file:../../com.unity.multiplayer.transport.utp",
99
"com.unity.package-validation-suite": "0.19.2-preview",
10-
"com.unity.services.authentication": "0.3.1-preview",
11-
"com.unity.services.core": "0.1.0-preview",
12-
"com.unity.services.relay": "0.0.1-preview.3",
10+
"com.unity.services.authentication": "0.5.0-preview",
11+
"com.unity.services.core": "1.1.0-pre.2",
12+
"com.unity.services.relay": "0.0.1-preview.5",
1313
"com.unity.test-framework": "1.1.24",
1414
"com.unity.textmeshpro": "3.0.4",
1515
"com.unity.timeline": "1.5.2",

testproject/Packages/packages-lock.json

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -116,34 +116,32 @@
116116
"url": "https://packages.unity.com"
117117
},
118118
"com.unity.services.authentication": {
119-
"version": "0.3.1-preview",
119+
"version": "0.5.0-preview",
120120
"depth": 0,
121121
"source": "registry",
122122
"dependencies": {
123-
"nuget.moq": "1.0.0",
124123
"com.unity.nuget.newtonsoft-json": "2.0.0",
125-
"com.unity.services.core": "0.2.0-preview",
124+
"com.unity.services.core": "1.1.0-pre.2",
126125
"com.unity.modules.unitywebrequest": "1.0.0"
127126
},
128127
"url": "https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-candidates"
129128
},
130129
"com.unity.services.core": {
131-
"version": "0.2.0-preview",
132-
"depth": 1,
130+
"version": "1.1.0-pre.2",
131+
"depth": 0,
133132
"source": "registry",
134133
"dependencies": {
135-
"nuget.moq": "1.0.0",
136134
"com.unity.modules.unitywebrequest": "1.0.0",
137135
"com.unity.nuget.newtonsoft-json": "2.0.0"
138136
},
139137
"url": "https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-candidates"
140138
},
141139
"com.unity.services.relay": {
142-
"version": "0.0.1-preview.3",
140+
"version": "0.0.1-preview.5",
143141
"depth": 0,
144142
"source": "registry",
145143
"dependencies": {
146-
"com.unity.services.core": "0.2.0-preview",
144+
"com.unity.services.core": "1.1.0-pre.2",
147145
"com.unity.modules.unitywebrequest": "1.0.0",
148146
"com.unity.modules.unitywebrequestassetbundle": "1.0.0",
149147
"com.unity.modules.unitywebrequestaudio": "1.0.0",
@@ -205,22 +203,6 @@
205203
"com.unity.modules.imgui": "1.0.0"
206204
}
207205
},
208-
"nuget.castle-core": {
209-
"version": "1.0.1",
210-
"depth": 2,
211-
"source": "registry",
212-
"dependencies": {},
213-
"url": "https://packages.unity.com"
214-
},
215-
"nuget.moq": {
216-
"version": "1.0.0",
217-
"depth": 1,
218-
"source": "registry",
219-
"dependencies": {
220-
"nuget.castle-core": "1.0.1"
221-
},
222-
"url": "https://packages.unity.com"
223-
},
224206
"com.unity.modules.ai": {
225207
"version": "1.0.0",
226208
"depth": 0,

testproject/ProjectSettings/ProjectSettings.asset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ PlayerSettings:
578578
webGLThreadsSupport: 0
579579
webGLDecompressionFallback: 0
580580
scriptingDefineSymbols:
581-
1: AUTHENTICATION_TESTING_STAGING_UAS;RELAY_BIGENDIAN
581+
1: AUTHENTICATION_TESTING_STAGING_UAS;
582582
additionalCompilerArguments: {}
583583
platformArchitecture: {}
584584
scriptingBackend: {}

0 commit comments

Comments
 (0)