From caa2bfda02604d2fb16cb6502d9db48f7cccbbe7 Mon Sep 17 00:00:00 2001 From: Rodolphe Houdas Date: Thu, 31 Aug 2023 14:29:53 +0100 Subject: [PATCH 1/8] Replace serverNameSpace with serviceIP and servicePort --- .../Editor/Scripts/LeapServiceProviderEditor.cs | 6 ++++-- .../Core/Runtime/Scripts/LeapServiceProvider.cs | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Packages/Tracking/Core/Editor/Scripts/LeapServiceProviderEditor.cs b/Packages/Tracking/Core/Editor/Scripts/LeapServiceProviderEditor.cs index 174f5e36fb..a2d8e35f94 100644 --- a/Packages/Tracking/Core/Editor/Scripts/LeapServiceProviderEditor.cs +++ b/Packages/Tracking/Core/Editor/Scripts/LeapServiceProviderEditor.cs @@ -63,7 +63,8 @@ protected override void OnEnable() specifyCustomDrawer("_specificSerialNumber", drawSerialNumberToggle); - deferProperty("_serverNameSpace"); + deferProperty("_servicePort"); + deferProperty("_serviceIP"); deferProperty("_useInterpolation"); deferProperty("_reconnectionAttempts"); @@ -78,7 +79,8 @@ protected override void OnEnable() hideField("_trackingOptimization"); } addPropertyToFoldout("_useInterpolation", "Advanced Options"); - addPropertyToFoldout("_serverNameSpace", "Advanced Options"); + addPropertyToFoldout("_serviceIP", "Advanced Options"); + addPropertyToFoldout("_servicePort", "Advanced Options"); addPropertyToFoldout("_reconnectionAttempts", "Advanced Options"); addPropertyToFoldout("_reconnectionInterval", "Advanced Options"); diff --git a/Packages/Tracking/Core/Runtime/Scripts/LeapServiceProvider.cs b/Packages/Tracking/Core/Runtime/Scripts/LeapServiceProvider.cs index 73cfb90f0b..bd02639008 100644 --- a/Packages/Tracking/Core/Runtime/Scripts/LeapServiceProvider.cs +++ b/Packages/Tracking/Core/Runtime/Scripts/LeapServiceProvider.cs @@ -269,10 +269,15 @@ public enum TrackingOptimizationMode [SerializeField] protected bool _preventInitializingTrackingMode; - [Tooltip("Which Leap Service API Endpoint to connect to. This is configured on the service with the 'api_namespace' argument.")] + [Tooltip("The IP address on which the Tracking service listens to. This is configured on the service with 'ip_address' in the 'leap_server_config' session of 'ServerConfig.json'")] [SerializeField] [EditTimeOnly] - protected string _serverNameSpace = "Leap Service"; + protected string _serviceIP = "127.0.0.1"; + + [Tooltip("The port on which the Tracking service listens to. This is configured on the service with 'port' in the 'leap_server_config' session of 'ServerConfig.json'")] + [SerializeField] + [EditTimeOnly] + protected string _servicePort = "12345"; public override TrackingSource TrackingDataSource { get { return CheckLeapServiceAvailable(); } } @@ -888,7 +893,9 @@ protected void createController() string serialNumber = _multipleDeviceMode != MultipleDeviceMode.Disabled ? SpecificSerialNumber : ""; - _leapController = new Controller(serialNumber.GetHashCode(), _serverNameSpace, _multipleDeviceMode != MultipleDeviceMode.Disabled); + string serverNameSpace = $"{{\"tracking_server_ip\": \"{_serviceIP}\", \"tracking_server_port\": {_servicePort}}}"; + + _leapController = new Controller(serialNumber.GetHashCode(), serverNameSpace, _multipleDeviceMode != MultipleDeviceMode.Disabled); _leapController.Device += (s, e) => { @@ -1066,8 +1073,9 @@ private TrackingSource CheckLeapServiceAvailable() return _trackingSource; } #endif + string serverNameSpace = $"{{\"tracking_server_ip\": \"{_serviceIP}\", \"tracking_server_port\": {_servicePort}}}"; - if (LeapInternal.Connection.IsConnectionAvailable(_serverNameSpace)) + if (LeapInternal.Connection.IsConnectionAvailable(serverNameSpace)) { _trackingSource = TrackingSource.LEAPC; } From 15becc0436dc75bb10f670d77495f63f2dd28d9d Mon Sep 17 00:00:00 2001 From: Rodolphe Houdas Date: Thu, 31 Aug 2023 15:00:39 +0100 Subject: [PATCH 2/8] Update CHANGELOG --- Packages/Tracking/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Packages/Tracking/CHANGELOG.md b/Packages/Tracking/CHANGELOG.md index cb64ae33cc..4c573c111c 100644 --- a/Packages/Tracking/CHANGELOG.md +++ b/Packages/Tracking/CHANGELOG.md @@ -12,7 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - ### Changed -- +- (Service Provider) Expose service IP and port as user settable variables ### Fixed - From 7d7d5e77689859582b39f792da7d432b2e3a96a5 Mon Sep 17 00:00:00 2001 From: Rodolphe Houdas Date: Thu, 31 Aug 2023 15:16:12 +0100 Subject: [PATCH 3/8] Re-introduce _serverNameSpace to avoid breaking serialization --- .../Editor/Scripts/LeapServiceProviderEditor.cs | 2 ++ .../Core/Runtime/Scripts/LeapServiceProvider.cs | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Packages/Tracking/Core/Editor/Scripts/LeapServiceProviderEditor.cs b/Packages/Tracking/Core/Editor/Scripts/LeapServiceProviderEditor.cs index a2d8e35f94..b50156f682 100644 --- a/Packages/Tracking/Core/Editor/Scripts/LeapServiceProviderEditor.cs +++ b/Packages/Tracking/Core/Editor/Scripts/LeapServiceProviderEditor.cs @@ -63,6 +63,7 @@ protected override void OnEnable() specifyCustomDrawer("_specificSerialNumber", drawSerialNumberToggle); + deferProperty("_serverNameSpace"); deferProperty("_servicePort"); deferProperty("_serviceIP"); deferProperty("_useInterpolation"); @@ -79,6 +80,7 @@ protected override void OnEnable() hideField("_trackingOptimization"); } addPropertyToFoldout("_useInterpolation", "Advanced Options"); + addPropertyToFoldout("_serverNameSpace", "Advanced Options"); addPropertyToFoldout("_serviceIP", "Advanced Options"); addPropertyToFoldout("_servicePort", "Advanced Options"); diff --git a/Packages/Tracking/Core/Runtime/Scripts/LeapServiceProvider.cs b/Packages/Tracking/Core/Runtime/Scripts/LeapServiceProvider.cs index bd02639008..b200c0c9b9 100644 --- a/Packages/Tracking/Core/Runtime/Scripts/LeapServiceProvider.cs +++ b/Packages/Tracking/Core/Runtime/Scripts/LeapServiceProvider.cs @@ -269,6 +269,11 @@ public enum TrackingOptimizationMode [SerializeField] protected bool _preventInitializingTrackingMode; + [Tooltip("[DEPRECATED] Which Leap Service API Endpoint to connect to. This is configured on the service with the 'api_namespace' argument.")] + [SerializeField] + [EditTimeOnly] + protected string _serverNameSpace = "Leap Service"; + [Tooltip("The IP address on which the Tracking service listens to. This is configured on the service with 'ip_address' in the 'leap_server_config' session of 'ServerConfig.json'")] [SerializeField] [EditTimeOnly] @@ -893,9 +898,9 @@ protected void createController() string serialNumber = _multipleDeviceMode != MultipleDeviceMode.Disabled ? SpecificSerialNumber : ""; - string serverNameSpace = $"{{\"tracking_server_ip\": \"{_serviceIP}\", \"tracking_server_port\": {_servicePort}}}"; + _serverNameSpace = $"{{\"tracking_server_ip\": \"{_serviceIP}\", \"tracking_server_port\": {_servicePort}}}"; - _leapController = new Controller(serialNumber.GetHashCode(), serverNameSpace, _multipleDeviceMode != MultipleDeviceMode.Disabled); + _leapController = new Controller(serialNumber.GetHashCode(), _serverNameSpace, _multipleDeviceMode != MultipleDeviceMode.Disabled); _leapController.Device += (s, e) => { @@ -1073,9 +1078,9 @@ private TrackingSource CheckLeapServiceAvailable() return _trackingSource; } #endif - string serverNameSpace = $"{{\"tracking_server_ip\": \"{_serviceIP}\", \"tracking_server_port\": {_servicePort}}}"; + _serverNameSpace = $"{{\"tracking_server_ip\": \"{_serviceIP}\", \"tracking_server_port\": {_servicePort}}}"; - if (LeapInternal.Connection.IsConnectionAvailable(serverNameSpace)) + if (LeapInternal.Connection.IsConnectionAvailable(_serverNameSpace)) { _trackingSource = TrackingSource.LEAPC; } From 8345e6238e271fbc7654157be78ca90e609ccaf6 Mon Sep 17 00:00:00 2001 From: Rodolphe Houdas Date: Thu, 31 Aug 2023 15:17:30 +0100 Subject: [PATCH 4/8] Only use IP and port if _serverNameSpace is left as default --- .../Core/Runtime/Scripts/LeapServiceProvider.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Packages/Tracking/Core/Runtime/Scripts/LeapServiceProvider.cs b/Packages/Tracking/Core/Runtime/Scripts/LeapServiceProvider.cs index b200c0c9b9..9c85ab5c0b 100644 --- a/Packages/Tracking/Core/Runtime/Scripts/LeapServiceProvider.cs +++ b/Packages/Tracking/Core/Runtime/Scripts/LeapServiceProvider.cs @@ -898,7 +898,10 @@ protected void createController() string serialNumber = _multipleDeviceMode != MultipleDeviceMode.Disabled ? SpecificSerialNumber : ""; - _serverNameSpace = $"{{\"tracking_server_ip\": \"{_serviceIP}\", \"tracking_server_port\": {_servicePort}}}"; + if (_serverNameSpace == "Leap Service") + { + _serverNameSpace = $"{{\"tracking_server_ip\": \"{_serviceIP}\", \"tracking_server_port\": {_servicePort}}}"; + } _leapController = new Controller(serialNumber.GetHashCode(), _serverNameSpace, _multipleDeviceMode != MultipleDeviceMode.Disabled); @@ -1078,7 +1081,10 @@ private TrackingSource CheckLeapServiceAvailable() return _trackingSource; } #endif - _serverNameSpace = $"{{\"tracking_server_ip\": \"{_serviceIP}\", \"tracking_server_port\": {_servicePort}}}"; + if (_serverNameSpace == "Leap Service") + { + _serverNameSpace = $"{{\"tracking_server_ip\": \"{_serviceIP}\", \"tracking_server_port\": {_servicePort}}}"; + } if (LeapInternal.Connection.IsConnectionAvailable(_serverNameSpace)) { From 670f8057266650d3a3ba79fb4a1b48716254cfca Mon Sep 17 00:00:00 2001 From: MattGray Date: Thu, 14 Sep 2023 12:42:41 +0100 Subject: [PATCH 5/8] Conditionally show IP and Port vs Name as inputs for the connection --- .../Scripts/LeapServiceProviderEditor.cs | 16 ++++++++++++++++ .../Runtime/Scripts/LeapServiceProvider.cs | 19 ++++++++++++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/Packages/Tracking/Core/Editor/Scripts/LeapServiceProviderEditor.cs b/Packages/Tracking/Core/Editor/Scripts/LeapServiceProviderEditor.cs index b50156f682..7c1a2c7b7c 100644 --- a/Packages/Tracking/Core/Editor/Scripts/LeapServiceProviderEditor.cs +++ b/Packages/Tracking/Core/Editor/Scripts/LeapServiceProviderEditor.cs @@ -63,6 +63,7 @@ protected override void OnEnable() specifyCustomDrawer("_specificSerialNumber", drawSerialNumberToggle); + deferProperty("_serverConnectionInput"); deferProperty("_serverNameSpace"); deferProperty("_servicePort"); deferProperty("_serviceIP"); @@ -80,6 +81,21 @@ protected override void OnEnable() hideField("_trackingOptimization"); } addPropertyToFoldout("_useInterpolation", "Advanced Options"); + + addPropertyToFoldout("_serviceConnectionInput", "Advanced Options"); + + specifyConditionalDrawing("_serviceConnectionInput", + (int)LeapServiceProvider.ServiceConnectionInput.NAME, + "_serverNameSpace"); + + specifyConditionalDrawing("_serviceConnectionInput", + (int)LeapServiceProvider.ServiceConnectionInput.IP_PORT, + "_serviceIP"); + + specifyConditionalDrawing("_serviceConnectionInput", + (int)LeapServiceProvider.ServiceConnectionInput.IP_PORT, + "_servicePort"); + addPropertyToFoldout("_serverNameSpace", "Advanced Options"); addPropertyToFoldout("_serviceIP", "Advanced Options"); addPropertyToFoldout("_servicePort", "Advanced Options"); diff --git a/Packages/Tracking/Core/Runtime/Scripts/LeapServiceProvider.cs b/Packages/Tracking/Core/Runtime/Scripts/LeapServiceProvider.cs index 9c85ab5c0b..1b73ef67db 100644 --- a/Packages/Tracking/Core/Runtime/Scripts/LeapServiceProvider.cs +++ b/Packages/Tracking/Core/Runtime/Scripts/LeapServiceProvider.cs @@ -269,7 +269,20 @@ public enum TrackingOptimizationMode [SerializeField] protected bool _preventInitializingTrackingMode; - [Tooltip("[DEPRECATED] Which Leap Service API Endpoint to connect to. This is configured on the service with the 'api_namespace' argument.")] + /// + /// The type of input to use for connection to the service + /// + public enum ServiceConnectionInput + { + NAME, + IP_PORT + } + [Tooltip("Which input to use for the service connection")] + [SerializeField] + [EditTimeOnly] + protected ServiceConnectionInput _serviceConnectionInput = ServiceConnectionInput.NAME; + + [Tooltip("Which Leap Service API Endpoint to connect to. This is configured on the service with the 'api_namespace' argument.")] [SerializeField] [EditTimeOnly] protected string _serverNameSpace = "Leap Service"; @@ -898,7 +911,7 @@ protected void createController() string serialNumber = _multipleDeviceMode != MultipleDeviceMode.Disabled ? SpecificSerialNumber : ""; - if (_serverNameSpace == "Leap Service") + if(_serviceConnectionInput == ServiceConnectionInput.IP_PORT) { _serverNameSpace = $"{{\"tracking_server_ip\": \"{_serviceIP}\", \"tracking_server_port\": {_servicePort}}}"; } @@ -1081,7 +1094,7 @@ private TrackingSource CheckLeapServiceAvailable() return _trackingSource; } #endif - if (_serverNameSpace == "Leap Service") + if (_serviceConnectionInput == ServiceConnectionInput.IP_PORT) { _serverNameSpace = $"{{\"tracking_server_ip\": \"{_serviceIP}\", \"tracking_server_port\": {_servicePort}}}"; } From b3f58ba0954bdb533438a703e9b3637701defad0 Mon Sep 17 00:00:00 2001 From: MattGray Date: Thu, 14 Sep 2023 12:46:48 +0100 Subject: [PATCH 6/8] ensure enum appears in correct location in inspector --- .../Tracking/Core/Editor/Scripts/LeapServiceProviderEditor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Packages/Tracking/Core/Editor/Scripts/LeapServiceProviderEditor.cs b/Packages/Tracking/Core/Editor/Scripts/LeapServiceProviderEditor.cs index 7c1a2c7b7c..de05f9af50 100644 --- a/Packages/Tracking/Core/Editor/Scripts/LeapServiceProviderEditor.cs +++ b/Packages/Tracking/Core/Editor/Scripts/LeapServiceProviderEditor.cs @@ -63,7 +63,7 @@ protected override void OnEnable() specifyCustomDrawer("_specificSerialNumber", drawSerialNumberToggle); - deferProperty("_serverConnectionInput"); + deferProperty("_serviceConnectionInput"); deferProperty("_serverNameSpace"); deferProperty("_servicePort"); deferProperty("_serviceIP"); From 999cf9468e2d9d8180acc9f55cac7af2871c69a8 Mon Sep 17 00:00:00 2001 From: MattGray Date: Mon, 30 Oct 2023 17:01:33 +0000 Subject: [PATCH 7/8] add ability to set the IP adn Port via code --- .../Core/Runtime/Scripts/LeapServiceProvider.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Packages/Tracking/Core/Runtime/Scripts/LeapServiceProvider.cs b/Packages/Tracking/Core/Runtime/Scripts/LeapServiceProvider.cs index 1b73ef67db..b19bf9f7aa 100644 --- a/Packages/Tracking/Core/Runtime/Scripts/LeapServiceProvider.cs +++ b/Packages/Tracking/Core/Runtime/Scripts/LeapServiceProvider.cs @@ -868,6 +868,20 @@ public TrackingOptimizationMode GetTrackingMode() throw new Exception("Unknown tracking optimization mode"); } + /// + /// Set the _serviceConnectionInput mode to IP_PORT, set the target IP and port of the service to the parameters and connect to the new service address + /// + public void SetServiceIPPort(string IP, string port) + { + _serviceConnectionInput = ServiceConnectionInput.IP_PORT; + + _serviceIP = IP; + _servicePort = port; + + destroyController(); + createController(); + } + #endregion #region Internal Methods From 7452b329a7cc4da3e094125f54a6e11c125ef8c9 Mon Sep 17 00:00:00 2001 From: MattGrayUL <60962475+MattGrayUL@users.noreply.github.com> Date: Mon, 30 Oct 2023 17:08:11 +0000 Subject: [PATCH 8/8] Update LeapServiceProvider.cs --- Packages/Tracking/Core/Runtime/Scripts/LeapServiceProvider.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Packages/Tracking/Core/Runtime/Scripts/LeapServiceProvider.cs b/Packages/Tracking/Core/Runtime/Scripts/LeapServiceProvider.cs index b19bf9f7aa..2ee2093925 100644 --- a/Packages/Tracking/Core/Runtime/Scripts/LeapServiceProvider.cs +++ b/Packages/Tracking/Core/Runtime/Scripts/LeapServiceProvider.cs @@ -871,7 +871,7 @@ public TrackingOptimizationMode GetTrackingMode() /// /// Set the _serviceConnectionInput mode to IP_PORT, set the target IP and port of the service to the parameters and connect to the new service address /// - public void SetServiceIPPort(string IP, string port) + public void SetTargetServiceIPPortToConnectTo(string IP, string port) { _serviceConnectionInput = ServiceConnectionInput.IP_PORT; @@ -1335,4 +1335,4 @@ public class LeapFOVInfo #endregion } -} \ No newline at end of file +}