diff --git a/com.unity.multiplayer.transport.utp/Runtime/UTPTransport.cs b/com.unity.multiplayer.transport.utp/Runtime/UTPTransport.cs index c73b897235..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); @@ -385,7 +367,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/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 1e9146d248..35c3aace1e 100644 --- a/testproject/Packages/manifest.json +++ b/testproject/Packages/manifest.json @@ -7,9 +7,9 @@ "com.unity.multiplayer.mlapi": "file:../../com.unity.multiplayer.mlapi", "com.unity.multiplayer.transport.utp": "file:../../com.unity.multiplayer.transport.utp", "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.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 4d6d3d74fa..7368b2b6eb 100644 --- a/testproject/Packages/packages-lock.json +++ b/testproject/Packages/packages-lock.json @@ -116,34 +116,32 @@ "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.3", + "version": "0.0.1-preview.5", "depth": 0, "source": "registry", "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", @@ -205,22 +203,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, 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: {}