From e8976407ca80f3a5d0dbb4169f131a6b3028a078 Mon Sep 17 00:00:00 2001 From: Fernando Galandrini Date: Wed, 16 Jun 2021 12:59:50 -0400 Subject: [PATCH 1/5] update to relay sdk v0.0.1-preview.4 --- com.unity.multiplayer.transport.utp/Runtime/UTPTransport.cs | 2 +- testproject/Packages/manifest.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/com.unity.multiplayer.transport.utp/Runtime/UTPTransport.cs b/com.unity.multiplayer.transport.utp/Runtime/UTPTransport.cs index c73b897235..8eb7573bb3 100644 --- a/com.unity.multiplayer.transport.utp/Runtime/UTPTransport.cs +++ b/com.unity.multiplayer.transport.utp/Runtime/UTPTransport.cs @@ -385,7 +385,7 @@ public override void Init() m_MessageBuffer = new byte[m_MessageBufferSize]; #if ENABLE_RELAY_SERVICE if (m_ProtocolType == ProtocolType.RelayUnityTransport) { - Unity.Services.Relay.Configuration.BasePath = m_RelayServer; + Unity.Services.Relay.RelayService.Configuration.BasePath = m_RelayServer; UnityServices.Initialize(); } #endif diff --git a/testproject/Packages/manifest.json b/testproject/Packages/manifest.json index 1e9146d248..bb4215454b 100644 --- a/testproject/Packages/manifest.json +++ b/testproject/Packages/manifest.json @@ -9,7 +9,7 @@ "com.unity.package-validation-suite": "0.19.2-preview", "com.unity.services.authentication": "0.3.1-preview", "com.unity.services.core": "0.1.0-preview", - "com.unity.services.relay": "0.0.1-preview.3", + "com.unity.services.relay": "0.0.1-preview.4", "com.unity.test-framework": "1.1.24", "com.unity.textmeshpro": "3.0.4", "com.unity.timeline": "1.5.2", From 93f41199904353b7c05eb46000926fad8a4b18a4 Mon Sep 17 00:00:00 2001 From: Fernando Galandrini Date: Wed, 16 Jun 2021 15:53:39 -0400 Subject: [PATCH 2/5] remove workarounds - use byte array representation of allocation id - connection data truncation is not longer needed - set default relay endpoint as production --- .../Runtime/UTPTransport.cs | 34 +++++-------------- testproject/Packages/manifest.json | 1 + testproject/Packages/packages-lock.json | 2 +- .../ProjectSettings/ProjectSettings.asset | 2 +- 4 files changed, 11 insertions(+), 28 deletions(-) diff --git a/com.unity.multiplayer.transport.utp/Runtime/UTPTransport.cs b/com.unity.multiplayer.transport.utp/Runtime/UTPTransport.cs index 8eb7573bb3..b01c4c702e 100644 --- a/com.unity.multiplayer.transport.utp/Runtime/UTPTransport.cs +++ b/com.unity.multiplayer.transport.utp/Runtime/UTPTransport.cs @@ -40,7 +40,7 @@ private enum State [SerializeField] private string m_ServerAddress = "127.0.0.1"; [SerializeField] private ushort m_ServerPort = 7777; [SerializeField] private int m_RelayMaxPlayers = 10; - [SerializeField] private string m_RelayServer = "https://relay-allocations-stg.cloud.unity3d.com"; + [SerializeField] private string m_RelayServer = "https://relay-allocations.cloud.unity3d.com"; private State m_State = State.Disconnected; private NetworkDriver m_Driver; @@ -95,20 +95,10 @@ private IEnumerator ClientBindAndConnect(SocketTask task) var allocation = joinTask.Result.Result.Data.Allocation; serverEndpoint = NetworkEndPoint.Parse(allocation.RelayServer.IpV4, (ushort)allocation.RelayServer.Port); -#if RELAY_BIGENDIAN - // TODO: endianess of Relay server does not match - var allocationIdArray = allocation.AllocationId.ToByteArray(); - Array.Reverse(allocationIdArray, 0, 4); - Array.Reverse(allocationIdArray, 4, 2); - Array.Reverse(allocationIdArray, 6, 2); - var allocationId = RelayAllocationId.FromByteArray(allocationIdArray); -#else - var allocationId = RelayAllocationId.FromByteArray(allocation.AllocationId.ToByteArray()); -#endif - - // TODO: workaround for receiving 271 bytes in connection data - var connectionData = RelayConnectionData.FromByteArray(allocation.ConnectionData.Take(255).ToArray()); - var hostConnectionData = RelayConnectionData.FromByteArray(allocation.HostConnectionData.Take(255).ToArray()); + var allocationId = RelayAllocationId.FromByteArray(allocation.AllocationIdBytes); + + var connectionData = RelayConnectionData.FromByteArray(allocation.ConnectionData); + var hostConnectionData = RelayConnectionData.FromByteArray(allocation.HostConnectionData); var key = RelayHMACKey.FromByteArray(allocation.Key); Debug.Log($"client: {allocation.ConnectionData[0]} {allocation.ConnectionData[1]}"); @@ -240,17 +230,9 @@ private IEnumerator StartRelayServer(SocketTask task) var serverEndpoint = NetworkEndPoint.Parse(allocation.RelayServer.IpV4, (ushort)allocation.RelayServer.Port); // Debug.Log($"Relay Server endpoint: {allocation.RelayServer.IpV4}:{(ushort)allocation.RelayServer.Port}"); -#if RELAY_BIGENDIAN - var allocationIdArray = allocation.AllocationId.ToByteArray(); - Array.Reverse(allocationIdArray, 0, 4); - Array.Reverse(allocationIdArray, 4, 2); - Array.Reverse(allocationIdArray, 6, 2); - var allocationId = RelayAllocationId.FromByteArray(allocationIdArray); -#else - var allocationId = RelayAllocationId.FromByteArray(allocation.AllocationId.ToByteArray()); -#endif - // TODO: connectionData should be 255 bytes, but we are getting 16 extra bytes - var connectionData = RelayConnectionData.FromByteArray(allocation.ConnectionData.Take(255).ToArray()); + var allocationId = RelayAllocationId.FromByteArray(allocation.AllocationIdBytes); + + var connectionData = RelayConnectionData.FromByteArray(allocation.ConnectionData); var key = RelayHMACKey.FromByteArray(allocation.Key); diff --git a/testproject/Packages/manifest.json b/testproject/Packages/manifest.json index bb4215454b..6d5286a211 100644 --- a/testproject/Packages/manifest.json +++ b/testproject/Packages/manifest.json @@ -6,6 +6,7 @@ "com.unity.ide.vscode": "1.2.3", "com.unity.multiplayer.mlapi": "file:../../com.unity.multiplayer.mlapi", "com.unity.multiplayer.transport.utp": "file:../../com.unity.multiplayer.transport.utp", + "com.unity.transport": "file:../../../com.unity.transport", "com.unity.package-validation-suite": "0.19.2-preview", "com.unity.services.authentication": "0.3.1-preview", "com.unity.services.core": "0.1.0-preview", diff --git a/testproject/Packages/packages-lock.json b/testproject/Packages/packages-lock.json index 4d6d3d74fa..62b9b9b2f1 100644 --- a/testproject/Packages/packages-lock.json +++ b/testproject/Packages/packages-lock.json @@ -139,7 +139,7 @@ "url": "https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-candidates" }, "com.unity.services.relay": { - "version": "0.0.1-preview.3", + "version": "0.0.1-preview.4", "depth": 0, "source": "registry", "dependencies": { diff --git a/testproject/ProjectSettings/ProjectSettings.asset b/testproject/ProjectSettings/ProjectSettings.asset index 541de0bf6e..8774ebb025 100644 --- a/testproject/ProjectSettings/ProjectSettings.asset +++ b/testproject/ProjectSettings/ProjectSettings.asset @@ -578,7 +578,7 @@ PlayerSettings: webGLThreadsSupport: 0 webGLDecompressionFallback: 0 scriptingDefineSymbols: - 1: AUTHENTICATION_TESTING_STAGING_UAS;RELAY_BIGENDIAN + 1: AUTHENTICATION_TESTING_STAGING_UAS; additionalCompilerArguments: {} platformArchitecture: {} scriptingBackend: {} From fb659e4a8948932eb81619d9efdae352f4074232 Mon Sep 17 00:00:00 2001 From: Fernando Galandrini Date: Thu, 17 Jun 2021 10:56:40 -0400 Subject: [PATCH 3/5] updated auth to v0.5.0 - updated core and authentication versions - updated relay version (compatible with latest core) - updated authentication calls --- .../Assets/Scripts/ConnectionModeScript.cs | 10 ++-- testproject/Assets/Scripts/UIController.cs | 6 +- testproject/Packages/manifest.json | 6 +- testproject/Packages/packages-lock.json | 57 +++++++------------ 4 files changed, 30 insertions(+), 49 deletions(-) diff --git a/testproject/Assets/Scripts/ConnectionModeScript.cs b/testproject/Assets/Scripts/ConnectionModeScript.cs index 68f3f96ac4..47f0cfdd30 100644 --- a/testproject/Assets/Scripts/ConnectionModeScript.cs +++ b/testproject/Assets/Scripts/ConnectionModeScript.cs @@ -68,8 +68,8 @@ private void Start() if (NetworkManager.Singleton.GetComponent().Protocol == UTPTransport.ProtocolType.RelayUnityTransport) { m_JoinCodeInput.SetActive(true); - m_ConnectionModeButtons.SetActive(false || Authentication.IsSignedIn); - m_AuthenticationButtons.SetActive(NetworkManager.Singleton && !NetworkManager.Singleton.IsListening && !Authentication.IsSignedIn); + m_ConnectionModeButtons.SetActive(false || AuthenticationService.Instance.IsSignedIn); + m_AuthenticationButtons.SetActive(NetworkManager.Singleton && !NetworkManager.Singleton.IsListening && !AuthenticationService.Instance.IsSignedIn); } else #endif @@ -128,10 +128,10 @@ public async void OnSignIn() { #if ENABLE_RELAY_SERVICE await UnityServices.Initialize(); - await Authentication.SignInAnonymously(); - Debug.Log($"Logging in with PlayerID {Authentication.PlayerId}"); + await AuthenticationService.Instance.SignInAnonymouslyAsync(); + Debug.Log($"Logging in with PlayerID {AuthenticationService.Instance.PlayerId}"); - if (Authentication.IsSignedIn) + if (AuthenticationService.Instance.IsSignedIn) { m_ConnectionModeButtons.SetActive(true); m_AuthenticationButtons.SetActive(false); diff --git a/testproject/Assets/Scripts/UIController.cs b/testproject/Assets/Scripts/UIController.cs index 870352f5c5..3a5969d3e1 100644 --- a/testproject/Assets/Scripts/UIController.cs +++ b/testproject/Assets/Scripts/UIController.cs @@ -54,10 +54,10 @@ public async void OnSignIn() #if ENABLE_RELAY_SERVICE await UnityServices.Initialize(); Debug.Log("OnSignIn"); - await Authentication.SignInAnonymously(); - Debug.Log($"Logging in with PlayerID {Authentication.PlayerId}"); + await AuthenticationService.Instance.SignInAnonymouslyAsync(); + Debug.Log($"Logging in with PlayerID {AuthenticationService.Instance.PlayerId}"); - if (Authentication.IsSignedIn) { + if (AuthenticationService.Instance.IsSignedIn) { ButtonsRoot.SetActive(true); JoinCode.SetActive(true); AuthButton.SetActive(false); diff --git a/testproject/Packages/manifest.json b/testproject/Packages/manifest.json index 6d5286a211..bf5fc23ad0 100644 --- a/testproject/Packages/manifest.json +++ b/testproject/Packages/manifest.json @@ -8,9 +8,9 @@ "com.unity.multiplayer.transport.utp": "file:../../com.unity.multiplayer.transport.utp", "com.unity.transport": "file:../../../com.unity.transport", "com.unity.package-validation-suite": "0.19.2-preview", - "com.unity.services.authentication": "0.3.1-preview", - "com.unity.services.core": "0.1.0-preview", - "com.unity.services.relay": "0.0.1-preview.4", + "com.unity.services.authentication": "0.5.0-preview", + "com.unity.services.core": "1.1.0-pre.2", + "com.unity.services.relay": "0.0.1-preview.5", "com.unity.test-framework": "1.1.24", "com.unity.textmeshpro": "3.0.4", "com.unity.timeline": "1.5.2", diff --git a/testproject/Packages/packages-lock.json b/testproject/Packages/packages-lock.json index 62b9b9b2f1..50b3e18d1b 100644 --- a/testproject/Packages/packages-lock.json +++ b/testproject/Packages/packages-lock.json @@ -2,7 +2,7 @@ "dependencies": { "com.unity.burst": { "version": "1.5.2", - "depth": 3, + "depth": 2, "source": "registry", "dependencies": { "com.unity.mathematics": "1.2.1" @@ -17,11 +17,12 @@ "url": "https://packages.unity.com" }, "com.unity.collections": { - "version": "1.0.0-pre.1", - "depth": 2, + "version": "1.0.0-pre.2", + "depth": 1, "source": "registry", "dependencies": { - "com.unity.burst": "1.5.2" + "com.unity.burst": "1.5.2", + "com.unity.test-framework": "1.1.22" }, "url": "https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-candidates" }, @@ -67,7 +68,7 @@ }, "com.unity.mathematics": { "version": "1.2.1", - "depth": 2, + "depth": 1, "source": "registry", "dependencies": {}, "url": "https://packages.unity.com" @@ -116,42 +117,39 @@ "url": "https://packages.unity.com" }, "com.unity.services.authentication": { - "version": "0.3.1-preview", + "version": "0.5.0-preview", "depth": 0, "source": "registry", "dependencies": { - "nuget.moq": "1.0.0", "com.unity.nuget.newtonsoft-json": "2.0.0", - "com.unity.services.core": "0.2.0-preview", + "com.unity.services.core": "1.1.0-pre.2", "com.unity.modules.unitywebrequest": "1.0.0" }, "url": "https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-candidates" }, "com.unity.services.core": { - "version": "0.2.0-preview", - "depth": 1, + "version": "1.1.0-pre.2", + "depth": 0, "source": "registry", "dependencies": { - "nuget.moq": "1.0.0", "com.unity.modules.unitywebrequest": "1.0.0", "com.unity.nuget.newtonsoft-json": "2.0.0" }, "url": "https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-candidates" }, "com.unity.services.relay": { - "version": "0.0.1-preview.4", + "version": "file:../../../com.unity.services.relay/com.unity.services.relay", "depth": 0, - "source": "registry", + "source": "local", "dependencies": { - "com.unity.services.core": "0.2.0-preview", + "com.unity.services.core": "1.1.0-pre.2", "com.unity.modules.unitywebrequest": "1.0.0", "com.unity.modules.unitywebrequestassetbundle": "1.0.0", "com.unity.modules.unitywebrequestaudio": "1.0.0", "com.unity.modules.unitywebrequesttexture": "1.0.0", "com.unity.modules.unitywebrequestwww": "1.0.0", "com.unity.nuget.newtonsoft-json": "2.0.0" - }, - "url": "https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-candidates" + } }, "com.unity.test-framework": { "version": "1.1.24", @@ -186,15 +184,14 @@ "url": "https://packages.unity.com" }, "com.unity.transport": { - "version": "0.8.0-preview.5", - "depth": 1, - "source": "registry", + "version": "file:../../../com.unity.transport", + "depth": 0, + "source": "local", "dependencies": { - "com.unity.collections": "1.0.0-pre.1", + "com.unity.collections": "1.0.0-pre.2", "com.unity.burst": "1.5.1", "com.unity.mathematics": "1.2.1" - }, - "url": "https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-candidates" + } }, "com.unity.ugui": { "version": "1.0.0", @@ -205,22 +202,6 @@ "com.unity.modules.imgui": "1.0.0" } }, - "nuget.castle-core": { - "version": "1.0.1", - "depth": 2, - "source": "registry", - "dependencies": {}, - "url": "https://packages.unity.com" - }, - "nuget.moq": { - "version": "1.0.0", - "depth": 1, - "source": "registry", - "dependencies": { - "nuget.castle-core": "1.0.1" - }, - "url": "https://packages.unity.com" - }, "com.unity.modules.ai": { "version": "1.0.0", "depth": 0, From 9402ca1b6b2cc98b8c91a91f5d7094c9ddf7c2a4 Mon Sep 17 00:00:00 2001 From: Fernando Galandrini Date: Thu, 17 Jun 2021 10:59:46 -0400 Subject: [PATCH 4/5] remove project dependency on utp --- testproject/Packages/manifest.json | 1 - testproject/Packages/packages-lock.json | 22 +++++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/testproject/Packages/manifest.json b/testproject/Packages/manifest.json index bf5fc23ad0..35c3aace1e 100644 --- a/testproject/Packages/manifest.json +++ b/testproject/Packages/manifest.json @@ -6,7 +6,6 @@ "com.unity.ide.vscode": "1.2.3", "com.unity.multiplayer.mlapi": "file:../../com.unity.multiplayer.mlapi", "com.unity.multiplayer.transport.utp": "file:../../com.unity.multiplayer.transport.utp", - "com.unity.transport": "file:../../../com.unity.transport", "com.unity.package-validation-suite": "0.19.2-preview", "com.unity.services.authentication": "0.5.0-preview", "com.unity.services.core": "1.1.0-pre.2", diff --git a/testproject/Packages/packages-lock.json b/testproject/Packages/packages-lock.json index 50b3e18d1b..5d2b648df1 100644 --- a/testproject/Packages/packages-lock.json +++ b/testproject/Packages/packages-lock.json @@ -2,7 +2,7 @@ "dependencies": { "com.unity.burst": { "version": "1.5.2", - "depth": 2, + "depth": 3, "source": "registry", "dependencies": { "com.unity.mathematics": "1.2.1" @@ -17,12 +17,11 @@ "url": "https://packages.unity.com" }, "com.unity.collections": { - "version": "1.0.0-pre.2", - "depth": 1, + "version": "1.0.0-pre.1", + "depth": 2, "source": "registry", "dependencies": { - "com.unity.burst": "1.5.2", - "com.unity.test-framework": "1.1.22" + "com.unity.burst": "1.5.2" }, "url": "https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-candidates" }, @@ -68,7 +67,7 @@ }, "com.unity.mathematics": { "version": "1.2.1", - "depth": 1, + "depth": 2, "source": "registry", "dependencies": {}, "url": "https://packages.unity.com" @@ -184,14 +183,15 @@ "url": "https://packages.unity.com" }, "com.unity.transport": { - "version": "file:../../../com.unity.transport", - "depth": 0, - "source": "local", + "version": "0.8.0-preview.5", + "depth": 1, + "source": "registry", "dependencies": { - "com.unity.collections": "1.0.0-pre.2", + "com.unity.collections": "1.0.0-pre.1", "com.unity.burst": "1.5.1", "com.unity.mathematics": "1.2.1" - } + }, + "url": "https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-candidates" }, "com.unity.ugui": { "version": "1.0.0", From 5aaf5250a300ac1b381a40f7469b21c3ea78cd26 Mon Sep 17 00:00:00 2001 From: Fernando Galandrini Date: Thu, 17 Jun 2021 14:04:48 -0400 Subject: [PATCH 5/5] revert accidental changes to package-lock --- testproject/Packages/packages-lock.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/testproject/Packages/packages-lock.json b/testproject/Packages/packages-lock.json index 5d2b648df1..7368b2b6eb 100644 --- a/testproject/Packages/packages-lock.json +++ b/testproject/Packages/packages-lock.json @@ -137,9 +137,9 @@ "url": "https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-candidates" }, "com.unity.services.relay": { - "version": "file:../../../com.unity.services.relay/com.unity.services.relay", + "version": "0.0.1-preview.5", "depth": 0, - "source": "local", + "source": "registry", "dependencies": { "com.unity.services.core": "1.1.0-pre.2", "com.unity.modules.unitywebrequest": "1.0.0", @@ -148,7 +148,8 @@ "com.unity.modules.unitywebrequesttexture": "1.0.0", "com.unity.modules.unitywebrequestwww": "1.0.0", "com.unity.nuget.newtonsoft-json": "2.0.0" - } + }, + "url": "https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-candidates" }, "com.unity.test-framework": { "version": "1.1.24",