From bb029221c0f6c65e25ae58c21b6027a894c76a86 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Wed, 3 Jun 2026 17:00:43 -0600 Subject: [PATCH] feat: Add DevelopmentServerAddress property for direct communication and update URL handling in MobileControl classes --- .../MobileControlTouchpanelController.cs | 14 ++++++++++++-- .../MobileControlTouchpanelProperties.cs | 9 +++++++++ .../MobileControlWebsocketServer.cs | 6 +++--- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/PepperDash.Essentials.MobileControl/Touchpanel/MobileControlTouchpanelController.cs b/src/PepperDash.Essentials.MobileControl/Touchpanel/MobileControlTouchpanelController.cs index 24b5e242..a8100e80 100644 --- a/src/PepperDash.Essentials.MobileControl/Touchpanel/MobileControlTouchpanelController.cs +++ b/src/PepperDash.Essentials.MobileControl/Touchpanel/MobileControlTouchpanelController.cs @@ -519,7 +519,7 @@ namespace PepperDash.Essentials.Touchpanel return false; }) ? csIpAddress.ToString() : processorIp; - var match = Regex.Match(url, @"^http://([^:/]+):\d+/mc/app\?token=.+$"); + var match = Regex.Match(url, @"^http://([^:/]+):\d+/mc/app/?\?token=.+$"); if (match.Success) { string ipa = match.Groups[1].Value; @@ -583,7 +583,17 @@ namespace PepperDash.Essentials.Touchpanel /// public void SetAppUrl(string url) { - _appUrl = GetUrlWithCorrectIp(url); + if(localConfig.DevelopmentServerAddress != null) + { + url = Regex.Replace(url, @"^http://[^/]+", $"http://{localConfig.DevelopmentServerAddress}"); + this.LogInformation("Using development server IP, updated URL: {url}", url); + } + else + { + url = GetUrlWithCorrectIp(url); + } + + _appUrl = url; AppUrlFeedback.FireUpdate(); } diff --git a/src/PepperDash.Essentials.MobileControl/Touchpanel/MobileControlTouchpanelProperties.cs b/src/PepperDash.Essentials.MobileControl/Touchpanel/MobileControlTouchpanelProperties.cs index cf022c16..c6658f9f 100644 --- a/src/PepperDash.Essentials.MobileControl/Touchpanel/MobileControlTouchpanelProperties.cs +++ b/src/PepperDash.Essentials.MobileControl/Touchpanel/MobileControlTouchpanelProperties.cs @@ -16,6 +16,15 @@ public class MobileControlTouchpanelProperties : CrestronTouchpanelPropertiesCon [JsonProperty("useDirectServer")] public bool UseDirectServer { get; set; } = false; + /// + /// Gets or sets the DevelopmentServerIp. Optional. If UseDirectServer is true, + /// this IP address will be used for direct communication between the mobile control and a development server running on the same local network. + /// This allows development using a Vite server for hot module replacement (HMR) and live reloading during development. + /// Specifying this property will override the default behavior of mobile control. + /// + [JsonProperty("developmentServerAddress", NullValueHandling = NullValueHandling.Ignore)] + public string DevelopmentServerAddress { get; set; } + /// /// Gets or sets the ZoomRoomController diff --git a/src/PepperDash.Essentials.MobileControl/WebSocketServer/MobileControlWebsocketServer.cs b/src/PepperDash.Essentials.MobileControl/WebSocketServer/MobileControlWebsocketServer.cs index af2cbe48..0334df39 100644 --- a/src/PepperDash.Essentials.MobileControl/WebSocketServer/MobileControlWebsocketServer.cs +++ b/src/PepperDash.Essentials.MobileControl/WebSocketServer/MobileControlWebsocketServer.cs @@ -403,11 +403,11 @@ namespace PepperDash.Essentials.WebSocketServer ip = csIpAddress.ToString(); } - var appUrl = $"http://{ip}:{_parent.Config.DirectServer.Port}/mc/app?token={touchpanel.Key}"; + var appUrl = $"http://{ip}:{_parent.Config.DirectServer.Port}/mc/app/?token={touchpanel.Key}"; this.LogVerbose("Sending URL {appUrl} to touchpanel {touchpanelKey}", appUrl, touchpanel.Touchpanel.Key); - touchpanel.Touchpanel.SetAppUrl($"http://{ip}:{_parent.Config.DirectServer.Port}/mc/app?token={touchpanel.Key}"); + touchpanel.Touchpanel.SetAppUrl($"http://{ip}:{_parent.Config.DirectServer.Port}/mc/app/?token={touchpanel.Key}"); } } @@ -1228,7 +1228,7 @@ namespace PepperDash.Essentials.WebSocketServer Config = _parent.GetConfigWithPluginVersion(), CodeExpires = new DateTime().AddYears(1), UserCode = bridge.UserCode, - UserAppUrl = string.Format("http://{0}:{1}/mc/app", + UserAppUrl = string.Format("http://{0}:{1}/mc/app/", CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0), Port), WebSocketUrl = wsUrl,