From af82ba2351b3f3c1ba614e972b11606f9ebb9209 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Thu, 10 Jul 2025 12:44:56 -0500 Subject: [PATCH] feat: all fullStatus messages are now client-specific --- .../Messengers/AudioCodecBaseMessenger.cs | 6 +- .../Messengers/CameraBaseMessenger.cs | 6 +- .../Messengers/DeviceInfoMessenger.cs | 3 +- .../Messengers/DevicePresetsModelMessenger.cs | 6 +- .../Messengers/DeviceVolumeMessenger.cs | 6 +- .../Messengers/GenericMessenger.cs | 6 +- .../ICommunicationMonitorMessenger.cs | 2 +- .../Messengers/IDspPresetsMessenger.cs | 2 +- .../IEssentialsRoomCombinerMessenger.cs | 72 ++--- .../IHasCurrentSourceInfoMessenger.cs | 2 +- .../Messengers/IHasInputsMessenger.cs | 6 +- .../IHasPowerControlWithFeedbackMessenger.cs | 6 +- .../IHasScheduleAwarenessMessenger.cs | 6 +- .../Messengers/IHumiditySensor.cs | 10 +- .../Messengers/ILevelControlsMessenger.cs | 2 +- .../Messengers/IMatrixRoutingMessenger.cs | 2 +- .../IProjectorScreenLiftControlMessenger.cs | 10 +- .../Messengers/IRunRouteActionMessenger.cs | 27 +- .../Messengers/ISelectableItemsMessenger.cs | 6 +- .../IShutdownPromptTimerMessenger.cs | 14 +- .../Messengers/ISwitchedOutputMessenger.cs | 33 ++- .../Messengers/ITechPasswordMessenger.cs | 6 +- .../Messengers/ITemperatureSensorMessenger.cs | 34 ++- .../Messengers/LightingBaseMessenger.cs | 25 +- .../Messengers/RoomEventScheduleMessenger.cs | 39 ++- .../Messengers/ShadeBaseMessenger.cs | 6 +- .../Messengers/SystemMonitorMessenger.cs | 12 +- .../Messengers/TwoWayDisplayBaseMessenger.cs | 40 ++- .../Messengers/VideoCodecBaseMessenger.cs | 267 +++++++++++++----- 29 files changed, 457 insertions(+), 205 deletions(-) diff --git a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/AudioCodecBaseMessenger.cs b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/AudioCodecBaseMessenger.cs index d29eede8..9bdb62cb 100644 --- a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/AudioCodecBaseMessenger.cs +++ b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/AudioCodecBaseMessenger.cs @@ -38,7 +38,7 @@ namespace PepperDash.Essentials.AppServer.Messengers { base.RegisterActions(); - AddAction("/fullStatus", (id, content) => SendAtcFullMessageObject()); + AddAction("/fullStatus", (id, content) => SendAtcFullMessageObject(id)); AddAction("/dial", (id, content) => { var msg = content.ToObject>(); @@ -101,7 +101,7 @@ namespace PepperDash.Essentials.AppServer.Messengers /// Helper method to build call status for vtc /// /// - private void SendAtcFullMessageObject() + private void SendAtcFullMessageObject(string id = null) { var info = Codec.CodecInfo; @@ -113,7 +113,7 @@ namespace PepperDash.Essentials.AppServer.Messengers { phoneNumber = info.PhoneNumber } - }) + }), clientId: id ); } } diff --git a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/CameraBaseMessenger.cs b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/CameraBaseMessenger.cs index 6e3bacd3..563db4f6 100644 --- a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/CameraBaseMessenger.cs +++ b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/CameraBaseMessenger.cs @@ -57,7 +57,7 @@ namespace PepperDash.Essentials.AppServer.Messengers { base.RegisterActions(); - AddAction("/fullStatus", (id, content) => SendCameraFullMessageObject()); + AddAction("/fullStatus", (id, content) => SendCameraFullMessageObject(id)); if (Camera is IHasCameraPtzControl ptzCamera) @@ -174,7 +174,7 @@ namespace PepperDash.Essentials.AppServer.Messengers /// /// Helper method to update the full status of the camera /// - private void SendCameraFullMessageObject() + private void SendCameraFullMessageObject(string id = null) { var presetList = new List(); @@ -189,7 +189,7 @@ namespace PepperDash.Essentials.AppServer.Messengers cameraMode = GetCameraMode(), hasPresets = Camera is IHasCameraPresets, presets = presetList - }) + }), clientId: id ); } diff --git a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/DeviceInfoMessenger.cs b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/DeviceInfoMessenger.cs index 153a4ed7..95cd34df 100644 --- a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/DeviceInfoMessenger.cs +++ b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/DeviceInfoMessenger.cs @@ -1,4 +1,5 @@ using System.Timers; +using Independentsoft.Exchange; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using PepperDash.Core; @@ -70,7 +71,7 @@ namespace PepperDash.Essentials.AppServer.Messengers AddAction("/fullStatus", (id, context) => PostStatusMessage(new DeviceInfoStateMessage { DeviceInfo = _deviceInfoProvider.DeviceInfo - })); + }, id)); AddAction("/update", (id, context) => _deviceInfoProvider.UpdateDeviceInfo()); } diff --git a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/DevicePresetsModelMessenger.cs b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/DevicePresetsModelMessenger.cs index 3e6229a9..0622ce73 100644 --- a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/DevicePresetsModelMessenger.cs +++ b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/DevicePresetsModelMessenger.cs @@ -29,12 +29,12 @@ namespace PepperDash.Essentials.AppServer.Messengers _presetsDevice = presetsDevice; } - private void SendPresets() + private void SendPresets(string id = null) { PostStatusMessage(new PresetStateMessage { Favorites = _presetsDevice.TvPresets.PresetsList - }); + }, id); } private void RecallPreset(ISetTopBoxNumericKeypad device, string channel) @@ -62,7 +62,7 @@ namespace PepperDash.Essentials.AppServer.Messengers this.LogInformation("getting full status for client {id}", id); try { - SendPresets(); + SendPresets(id); } catch (Exception ex) { diff --git a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/DeviceVolumeMessenger.cs b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/DeviceVolumeMessenger.cs index 84c840f8..fe5a35a3 100644 --- a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/DeviceVolumeMessenger.cs +++ b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/DeviceVolumeMessenger.cs @@ -27,7 +27,7 @@ namespace PepperDash.Essentials.AppServer.Messengers _localDevice = device; } - private void SendStatus() + private void SendStatus(string id = null) { try { @@ -47,7 +47,7 @@ namespace PepperDash.Essentials.AppServer.Messengers messageObj.Volume.Units = volumeAdvanced.Units; } - PostStatusMessage(messageObj); + PostStatusMessage(messageObj, id); } catch (Exception ex) { @@ -64,7 +64,7 @@ namespace PepperDash.Essentials.AppServer.Messengers /// protected override void RegisterActions() { - AddAction("/fullStatus", (id, content) => SendStatus()); + AddAction("/fullStatus", (id, content) => SendStatus(id)); AddAction("/level", (id, content) => { diff --git a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/GenericMessenger.cs b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/GenericMessenger.cs index 50a329a0..fc1a9418 100644 --- a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/GenericMessenger.cs +++ b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/GenericMessenger.cs @@ -22,14 +22,14 @@ namespace PepperDash.Essentials.AppServer.Messengers { base.RegisterActions(); - AddAction("/fullStatus", (id, content) => SendFullStatus()); + AddAction("/fullStatus", (id, content) => SendFullStatus(id)); } - private void SendFullStatus() + private void SendFullStatus(string id = null) { var state = new DeviceStateMessageBase(); - PostStatusMessage(state); + PostStatusMessage(state, id); } } } diff --git a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/ICommunicationMonitorMessenger.cs b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/ICommunicationMonitorMessenger.cs index 119b9ff3..932f38a9 100644 --- a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/ICommunicationMonitorMessenger.cs +++ b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/ICommunicationMonitorMessenger.cs @@ -42,7 +42,7 @@ namespace PepperDash.Essentials.AppServer.Messengers IsOnline = _communicationMonitor.CommunicationMonitor.IsOnline, Status = _communicationMonitor.CommunicationMonitor.Status } - }); + }, id); }); _communicationMonitor.CommunicationMonitor.StatusChange += (sender, args) => diff --git a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IDspPresetsMessenger.cs b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IDspPresetsMessenger.cs index f3e58956..91442fea 100644 --- a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IDspPresetsMessenger.cs +++ b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IDspPresetsMessenger.cs @@ -40,7 +40,7 @@ namespace PepperDash.Essentials.AppServer.Messengers Presets = device.Presets }; - PostStatusMessage(message); + PostStatusMessage(message, id); }); AddAction("/recallPreset", (id, content) => diff --git a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IEssentialsRoomCombinerMessenger.cs b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IEssentialsRoomCombinerMessenger.cs index 1752b567..42dcd131 100644 --- a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IEssentialsRoomCombinerMessenger.cs +++ b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IEssentialsRoomCombinerMessenger.cs @@ -1,17 +1,17 @@ -using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using Newtonsoft.Json; using Newtonsoft.Json.Linq; using PepperDash.Core; using PepperDash.Core.Logging; using PepperDash.Essentials.Core; -using System; -using System.Collections.Generic; namespace PepperDash.Essentials.AppServer.Messengers { - /// - /// Provides messaging functionality for managing room combination scenarios and partition states in an instance. Enables external systems to interact with the room combiner via - /// predefined actions and status updates. + /// + /// Provides messaging functionality for managing room combination scenarios and partition states in an instance. Enables external systems to interact with the room combiner via + /// predefined actions and status updates. /// /// This class facilitates communication with an by /// exposing actions for toggling modes, managing partitions, and setting room combination scenarios. It also @@ -21,15 +21,15 @@ namespace PepperDash.Essentials.AppServer.Messengers { private readonly IEssentialsRoomCombiner _roomCombiner; - /// - /// Initializes a new instance of the class, which facilitates - /// messaging for an instance. - /// - /// This class is designed to enable communication and interaction with an through the specified messaging path. Ensure that the parameter is not null when creating an instance. - /// The unique key identifying this messenger instance. - /// The path used for messaging operations. + /// + /// Initializes a new instance of the class, which facilitates + /// messaging for an instance. + /// + /// This class is designed to enable communication and interaction with an through the specified messaging path. Ensure that the parameter is not null when creating an instance. + /// The unique key identifying this messenger instance. + /// The path used for messaging operations. /// The instance associated with this messenger. public IEssentialsRoomCombinerMessenger(string key, string messagePath, IEssentialsRoomCombiner roomCombiner) : base(key, messagePath, roomCombiner as IKeyName) @@ -37,8 +37,8 @@ namespace PepperDash.Essentials.AppServer.Messengers _roomCombiner = roomCombiner; } - /// - /// Registers actions and event handlers for managing room combination scenarios and partition states. + /// + /// Registers actions and event handlers for managing room combination scenarios and partition states. /// /// This method sets up various actions that can be triggered via specific endpoints, /// such as toggling modes, setting room combination scenarios, and managing partition states. It also @@ -46,7 +46,7 @@ namespace PepperDash.Essentials.AppServer.Messengers /// partition states. protected override void RegisterActions() { - AddAction("/fullStatus", (id, content) => SendFullStatus()); + AddAction("/fullStatus", (id, content) => SendFullStatus(id)); AddAction("/setAutoMode", (id, content) => { @@ -120,7 +120,7 @@ namespace PepperDash.Essentials.AppServer.Messengers } } - private void SendFullStatus() + private void SendFullStatus(string id = null) { try { @@ -141,7 +141,7 @@ namespace PepperDash.Essentials.AppServer.Messengers Partitions = _roomCombiner.Partitions }; - PostStatusMessage(message); + PostStatusMessage(message, id); } catch (Exception e) { @@ -159,47 +159,47 @@ namespace PepperDash.Essentials.AppServer.Messengers } } - /// - /// Represents the state message for a room combiner system, providing information about the current configuration, - /// operational mode, and associated rooms, partitions, and scenarios. + /// + /// Represents the state message for a room combiner system, providing information about the current configuration, + /// operational mode, and associated rooms, partitions, and scenarios. /// /// This class is used to encapsulate the state of a room combiner system, including its current /// mode of operation, active room combination scenario, and the list of rooms and partitions involved. It is /// typically serialized and transmitted to communicate the state of the system. public class IEssentialsRoomCombinerStateMessage : DeviceStateMessageBase { - /// - /// Gets or sets a value indicating whether automatic mode is disabled. + /// + /// Gets or sets a value indicating whether automatic mode is disabled. /// [JsonProperty("disableAutoMode", NullValueHandling = NullValueHandling.Ignore)] public bool DisableAutoMode { get; set; } - /// - /// Gets or sets a value indicating whether the system is operating in automatic mode. + /// + /// Gets or sets a value indicating whether the system is operating in automatic mode. /// [JsonProperty("isInAutoMode", NullValueHandling = NullValueHandling.Ignore)] public bool IsInAutoMode { get; set; } - /// - /// Gets or sets the current room combination scenario. + /// + /// Gets or sets the current room combination scenario. /// [JsonProperty("currentScenario", NullValueHandling = NullValueHandling.Ignore)] public IRoomCombinationScenario CurrentScenario { get; set; } - /// - /// Gets or sets the collection of rooms associated with the entity. + /// + /// Gets or sets the collection of rooms associated with the entity. /// [JsonProperty("rooms", NullValueHandling = NullValueHandling.Ignore)] public List Rooms { get; set; } - /// - /// Gets or sets the collection of room combination scenarios. + /// + /// Gets or sets the collection of room combination scenarios. /// [JsonProperty("roomCombinationScenarios", NullValueHandling = NullValueHandling.Ignore)] public List RoomCombinationScenarios { get; set; } - /// - /// Gets or sets the collection of partition controllers. + /// + /// Gets or sets the collection of partition controllers. /// [JsonProperty("partitions", NullValueHandling = NullValueHandling.Ignore)] public List Partitions { get; set; } diff --git a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IHasCurrentSourceInfoMessenger.cs b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IHasCurrentSourceInfoMessenger.cs index d7102418..9e87bccb 100644 --- a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IHasCurrentSourceInfoMessenger.cs +++ b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IHasCurrentSourceInfoMessenger.cs @@ -36,7 +36,7 @@ namespace PepperDash.Essentials.AppServer.Messengers CurrentSource = sourceDevice.CurrentSourceInfo }; - PostStatusMessage(message); + PostStatusMessage(message, id); }); sourceDevice.CurrentSourceChange += (sender, e) => diff --git a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IHasInputsMessenger.cs b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IHasInputsMessenger.cs index b22dd881..5df613f1 100644 --- a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IHasInputsMessenger.cs +++ b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IHasInputsMessenger.cs @@ -34,7 +34,7 @@ namespace PepperDash.Essentials.AppServer.Messengers AddAction("/fullStatus", (id, context) => { - SendFullStatus(); + SendFullStatus(id); }); itemDevice.Inputs.ItemsUpdated += (sender, args) => @@ -64,7 +64,7 @@ namespace PepperDash.Essentials.AppServer.Messengers } } - private void SendFullStatus() + private void SendFullStatus(string id = null) { try { @@ -79,7 +79,7 @@ namespace PepperDash.Essentials.AppServer.Messengers } }; - PostStatusMessage(stateObject); + PostStatusMessage(stateObject, id); } catch (Exception e) { diff --git a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IHasPowerControlWithFeedbackMessenger.cs b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IHasPowerControlWithFeedbackMessenger.cs index 493c03d3..cefc96b9 100644 --- a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IHasPowerControlWithFeedbackMessenger.cs +++ b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IHasPowerControlWithFeedbackMessenger.cs @@ -28,14 +28,14 @@ namespace PepperDash.Essentials.AppServer.Messengers /// /// Sends the full power control status to connected clients. /// - public void SendFullStatus() + public void SendFullStatus(string id = null) { var messageObj = new PowerControlWithFeedbackStateMessage { PowerState = _powerControl.PowerIsOnFeedback.BoolValue }; - PostStatusMessage(messageObj); + PostStatusMessage(messageObj, id); } /// @@ -46,7 +46,7 @@ namespace PepperDash.Essentials.AppServer.Messengers { base.RegisterActions(); - AddAction("/fullStatus", (id, content) => SendFullStatus()); + AddAction("/fullStatus", (id, content) => SendFullStatus(id)); _powerControl.PowerIsOnFeedback.OutputChange += PowerIsOnFeedback_OutputChange; ; } diff --git a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IHasScheduleAwarenessMessenger.cs b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IHasScheduleAwarenessMessenger.cs index 1f5a9e50..e48ddcc3 100644 --- a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IHasScheduleAwarenessMessenger.cs +++ b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IHasScheduleAwarenessMessenger.cs @@ -34,7 +34,7 @@ namespace PepperDash.Essentials.AppServer.Messengers /// protected override void RegisterActions() { - AddAction("/schedule/fullStatus", (id, content) => SendFullScheduleObject()); + AddAction("/schedule/fullStatus", (id, content) => SendFullScheduleObject(id)); } private void CodecSchedule_MeetingEventChange(object sender, MeetingEventArgs e) @@ -58,13 +58,13 @@ namespace PepperDash.Essentials.AppServer.Messengers /// /// Helper method to send the full schedule data /// - private void SendFullScheduleObject() + private void SendFullScheduleObject(string id = null) { PostStatusMessage(new FullScheduleMessage { Meetings = ScheduleSource.CodecSchedule.Meetings, MeetingWarningMinutes = ScheduleSource.CodecSchedule.MeetingWarningMinutes - }); + }, id); } } diff --git a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IHumiditySensor.cs b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IHumiditySensor.cs index c44ec9ae..1bdacc73 100644 --- a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IHumiditySensor.cs +++ b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IHumiditySensor.cs @@ -1,7 +1,7 @@ -using Newtonsoft.Json; +using System; +using Newtonsoft.Json; using PepperDash.Core; using PepperDash.Essentials.Core.DeviceTypeInterfaces; -using System; namespace PepperDash.Essentials.AppServer.Messengers { @@ -19,19 +19,19 @@ namespace PepperDash.Essentials.AppServer.Messengers { base.RegisterActions(); - AddAction("/fullStatus", (id, content) => SendFullStatus()); + AddAction("/fullStatus", (id, content) => SendFullStatus(id)); device.HumidityFeedback.OutputChange += new EventHandler((o, a) => SendFullStatus()); } - private void SendFullStatus() + private void SendFullStatus(string id = null) { var state = new IHumiditySensorStateMessage { Humidity = string.Format("{0}%", device.HumidityFeedback.UShortValue) }; - PostStatusMessage(state); + PostStatusMessage(state, id); } } diff --git a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/ILevelControlsMessenger.cs b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/ILevelControlsMessenger.cs index 68860052..06deb39e 100644 --- a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/ILevelControlsMessenger.cs +++ b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/ILevelControlsMessenger.cs @@ -37,7 +37,7 @@ namespace PepperDash.Essentials.AppServer.Messengers Levels = levelControlsDevice.LevelControlPoints.ToDictionary(kv => kv.Key, kv => new Volume { Level = kv.Value.VolumeLevelFeedback.IntValue, Muted = kv.Value.MuteFeedback.BoolValue }) }; - PostStatusMessage(message); + PostStatusMessage(message, id); }); foreach (var levelControl in levelControlsDevice.LevelControlPoints) diff --git a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IMatrixRoutingMessenger.cs b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IMatrixRoutingMessenger.cs index 35a6ceb2..2d9a1437 100644 --- a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IMatrixRoutingMessenger.cs +++ b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IMatrixRoutingMessenger.cs @@ -45,7 +45,7 @@ namespace PepperDash.Essentials.AppServer.Messengers }; - PostStatusMessage(message); + PostStatusMessage(message, id); } catch (Exception e) { diff --git a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IProjectorScreenLiftControlMessenger.cs b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IProjectorScreenLiftControlMessenger.cs index a66a8586..72cfb0a7 100644 --- a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IProjectorScreenLiftControlMessenger.cs +++ b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IProjectorScreenLiftControlMessenger.cs @@ -1,9 +1,9 @@ -using Newtonsoft.Json; +using System; +using Newtonsoft.Json; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; using PepperDash.Core; using PepperDash.Essentials.Core.DeviceTypeInterfaces; -using System; namespace PepperDash.Essentials.AppServer.Messengers { @@ -21,7 +21,7 @@ namespace PepperDash.Essentials.AppServer.Messengers { base.RegisterActions(); - AddAction("/fullStatus", (id, content) => SendFullStatus()); + AddAction("/fullStatus", (id, content) => SendFullStatus(id)); AddAction("/raise", (id, content) => { @@ -50,7 +50,7 @@ namespace PepperDash.Essentials.AppServer.Messengers PostStatusMessage(JToken.FromObject(state)); } - private void SendFullStatus() + private void SendFullStatus(string id = null) { var state = new ScreenLiftStateMessage { @@ -59,7 +59,7 @@ namespace PepperDash.Essentials.AppServer.Messengers DisplayDeviceKey = device.DisplayDeviceKey }; - PostStatusMessage(state); + PostStatusMessage(state, id); } } diff --git a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IRunRouteActionMessenger.cs b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IRunRouteActionMessenger.cs index 8ca6668b..ca374009 100644 --- a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IRunRouteActionMessenger.cs +++ b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IRunRouteActionMessenger.cs @@ -1,12 +1,15 @@ -using Newtonsoft.Json; +using System; +using Newtonsoft.Json; using PepperDash.Core; using PepperDash.Core.Logging; using PepperDash.Essentials.Core; -using System; namespace PepperDash.Essentials.AppServer.Messengers { + /// + /// Messenger for routing actions + /// public class RunRouteActionMessenger : MessengerBase { /// @@ -14,6 +17,13 @@ namespace PepperDash.Essentials.AppServer.Messengers /// public IRunRouteAction RoutingDevice { get; private set; } + /// + /// Initializes a new instance of the class. + /// + /// Unique identifier for the messenger + /// Device that implements IRunRouteAction + /// Path for message routing + /// Thrown when routingDevice is null public RunRouteActionMessenger(string key, IRunRouteAction routingDevice, string messagePath) : base(key, messagePath, routingDevice as IKeyName) { @@ -31,9 +41,10 @@ namespace PepperDash.Essentials.AppServer.Messengers SendRoutingFullMessageObject(); } + /// protected override void RegisterActions() { - AddAction("/fullStatus", (id, content) => SendRoutingFullMessageObject()); + AddAction("/fullStatus", (id, content) => SendRoutingFullMessageObject(id)); AddAction("/source", (id, content) => { @@ -59,7 +70,7 @@ namespace PepperDash.Essentials.AppServer.Messengers /// /// Helper method to update full status of the routing device /// - private void SendRoutingFullMessageObject() + private void SendRoutingFullMessageObject(string id = null) { if (RoutingDevice is IRoutingSink sinkDevice) { @@ -71,13 +82,19 @@ namespace PepperDash.Essentials.AppServer.Messengers PostStatusMessage(new RoutingStateMessage { SelectedSourceKey = sourceKey - }); + }, id); } } } + /// + /// Message class for routing state + /// public class RoutingStateMessage : DeviceStateMessageBase { + /// + /// Gets or sets the selected source key + /// [JsonProperty("selectedSourceKey")] public string SelectedSourceKey { get; set; } } diff --git a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/ISelectableItemsMessenger.cs b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/ISelectableItemsMessenger.cs index af74a929..9c2c2924 100644 --- a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/ISelectableItemsMessenger.cs +++ b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/ISelectableItemsMessenger.cs @@ -37,7 +37,7 @@ namespace PepperDash.Essentials.AppServer.Messengers AddAction("/fullStatus", (id, context) => { - SendFullStatus(); + SendFullStatus(id); }); itemDevice.ItemsUpdated += (sender, args) => @@ -67,7 +67,7 @@ namespace PepperDash.Essentials.AppServer.Messengers } } - private void SendFullStatus() + private void SendFullStatus(string id = null) { try { @@ -79,7 +79,7 @@ namespace PepperDash.Essentials.AppServer.Messengers CurrentItem = itemDevice.CurrentItem }; - PostStatusMessage(stateObject); + PostStatusMessage(stateObject, id); } catch (Exception e) { diff --git a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IShutdownPromptTimerMessenger.cs b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IShutdownPromptTimerMessenger.cs index ca5fc3d3..b93a086a 100644 --- a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IShutdownPromptTimerMessenger.cs +++ b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IShutdownPromptTimerMessenger.cs @@ -5,16 +5,26 @@ using PepperDash.Essentials.Core; namespace PepperDash.Essentials.AppServer.Messengers { + /// + /// Messenger for the shutdown prompt timer + /// public class IShutdownPromptTimerMessenger : MessengerBase { private readonly IShutdownPromptTimer _room; + /// + /// Initializes a new instance of the class. + /// + /// Unique identifier for the messenger + /// Path for message routing + /// Room that implements IShutdownPromptTimer public IShutdownPromptTimerMessenger(string key, string messagePath, IShutdownPromptTimer room) : base(key, messagePath, room as IKeyName) { _room = room; } + /// protected override void RegisterActions() { AddAction("/status", (id, content) => @@ -65,7 +75,7 @@ namespace PepperDash.Essentials.AppServer.Messengers }; } - private void SendFullStatus() + private void SendFullStatus(string id = null) { var status = new IShutdownPromptTimerStateMessage { @@ -74,7 +84,7 @@ namespace PepperDash.Essentials.AppServer.Messengers PercentageRemaining = _room.ShutdownPromptTimer.PercentFeedback.UShortValue }; - PostStatusMessage(status); + PostStatusMessage(status, id); } } diff --git a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/ISwitchedOutputMessenger.cs b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/ISwitchedOutputMessenger.cs index f49d189d..1fb9e03c 100644 --- a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/ISwitchedOutputMessenger.cs +++ b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/ISwitchedOutputMessenger.cs @@ -1,26 +1,39 @@ -using Newtonsoft.Json; +using System; +using Newtonsoft.Json; using PepperDash.Core; using PepperDash.Essentials.Core.CrestronIO; -using System; namespace PepperDash.Essentials.AppServer.Messengers { + /// + /// Messenger for ISwitchedOutput devices + /// public class ISwitchedOutputMessenger : MessengerBase { private readonly ISwitchedOutput device; + /// + /// Initializes a new instance of the class. + /// This messenger provides mobile control interface for switched output devices. + /// It allows sending commands to turn the output on or off, and provides feedback on the + /// current state of the output. + /// + /// Unique identifier for the messenger + /// Device that implements ISwitchedOutput + /// Path for message routing public ISwitchedOutputMessenger(string key, ISwitchedOutput device, string messagePath) : base(key, messagePath, device as IKeyName) { this.device = device; } + /// protected override void RegisterActions() { base.RegisterActions(); - AddAction("/fullStatus", (id, content) => SendFullStatus()); + AddAction("/fullStatus", (id, content) => SendFullStatus(id)); AddAction("/on", (id, content) => { @@ -39,19 +52,29 @@ namespace PepperDash.Essentials.AppServer.Messengers device.OutputIsOnFeedback.OutputChange += new EventHandler((o, a) => SendFullStatus()); } - private void SendFullStatus() + private void SendFullStatus(string id = null) { var state = new ISwitchedOutputStateMessage { IsOn = device.OutputIsOnFeedback.BoolValue }; - PostStatusMessage(state); + PostStatusMessage(state, id); } } + /// + /// State message for ISwitchedOutput devices + /// This message contains the current state of the switched output, specifically whether it is on or off. + /// It is used to communicate the state of the output to clients that subscribe to this messenger. + /// public class ISwitchedOutputStateMessage : DeviceStateMessageBase { + /// + /// Gets or sets a value indicating whether the switched output is currently on. + /// This property is used to convey the current state of the output to clients. + /// A value of true indicates that the output is on, while false indicates it is off. + /// [JsonProperty("isOn")] public bool IsOn { get; set; } } diff --git a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/ITechPasswordMessenger.cs b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/ITechPasswordMessenger.cs index 87450258..f9b11e54 100644 --- a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/ITechPasswordMessenger.cs +++ b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/ITechPasswordMessenger.cs @@ -29,7 +29,7 @@ namespace PepperDash.Essentials.AppServer.Messengers AddAction("/status", (id, content) => { - SendFullStatus(); + SendFullStatus(id); }); AddAction("/validateTechPassword", (id, content) => @@ -62,14 +62,14 @@ namespace PepperDash.Essentials.AppServer.Messengers }; } - private void SendFullStatus() + private void SendFullStatus(string id = null) { var status = new ITechPasswordStateMessage { TechPasswordLength = _room.TechPasswordLength }; - PostStatusMessage(status); + PostStatusMessage(status, id); } } diff --git a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/ITemperatureSensorMessenger.cs b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/ITemperatureSensorMessenger.cs index 6f7371c1..82ebf900 100644 --- a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/ITemperatureSensorMessenger.cs +++ b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/ITemperatureSensorMessenger.cs @@ -1,25 +1,37 @@ -using Newtonsoft.Json; +using System; +using Newtonsoft.Json; using PepperDash.Core; using PepperDash.Essentials.Core.DeviceTypeInterfaces; -using System; namespace PepperDash.Essentials.AppServer.Messengers { + /// + /// Messenger for temperature sensor devices + /// public class ITemperatureSensorMessenger : MessengerBase { private readonly ITemperatureSensor device; + /// + /// Initializes a new instance of the ITemperatureSensorMessenger class + /// This messenger provides a mobile control interface for temperature sensor devices. + /// It allows clients to retrieve the current temperature and change the temperature format between Celsius and Fahrenheit. + /// + /// Unique identifier for the messenger + /// Device that implements ITemperatureSensor + /// Path for message routing public ITemperatureSensorMessenger(string key, ITemperatureSensor device, string messagePath) : base(key, messagePath, device as IKeyName) { this.device = device; } + /// protected override void RegisterActions() { base.RegisterActions(); - AddAction("/fullStatus", (id, content) => SendFullStatus()); + AddAction("/fullStatus", (id, content) => SendFullStatus(id)); AddAction("/setTemperatureUnitsToCelcius", (id, content) => { @@ -35,7 +47,7 @@ namespace PepperDash.Essentials.AppServer.Messengers device.TemperatureInCFeedback.OutputChange += new EventHandler((o, a) => SendFullStatus()); } - private void SendFullStatus() + private void SendFullStatus(string id = null) { // format the temperature to a string with one decimal place var tempString = string.Format("{0}.{1}", device.TemperatureFeedback.UShortValue / 10, device.TemperatureFeedback.UShortValue % 10); @@ -46,15 +58,27 @@ namespace PepperDash.Essentials.AppServer.Messengers TemperatureInCelsius = device.TemperatureInCFeedback.BoolValue }; - PostStatusMessage(state); + PostStatusMessage(state, id); } } + /// + /// State message for temperature sensor devices + /// public class ITemperatureSensorStateMessage : DeviceStateMessageBase { + /// + /// Gets or sets the current temperature reading from the sensor. + /// The temperature is represented as a string formatted to one decimal place. + /// For example, "22.5" for 22.5 degrees. + /// [JsonProperty("temperature")] public string Temperature { get; set; } + /// + /// Gets or sets a value indicating whether the temperature is in Celsius. + /// This property is true if the temperature is in Celsius, and false if it is in Fahrenheit. + /// [JsonProperty("temperatureInCelsius")] public bool TemperatureInCelsius { get; set; } } diff --git a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/LightingBaseMessenger.cs b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/LightingBaseMessenger.cs index 8ae91d36..064bc946 100644 --- a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/LightingBaseMessenger.cs +++ b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/LightingBaseMessenger.cs @@ -1,15 +1,25 @@ -using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using Newtonsoft.Json; using PepperDash.Core; using PepperDash.Essentials.Core.Lighting; -using System; -using System.Collections.Generic; namespace PepperDash.Essentials.AppServer.Messengers { + /// + /// Messenger for lighting scenes devices + /// public class ILightingScenesMessenger : MessengerBase { private ILightingScenes lightingScenesDevice; + /// + /// Initializes a new instance of the class. + /// + /// Unique identifier for the messenger + /// Device that implements ILightingScenes + /// Path for message routing + /// Thrown when device is null public ILightingScenesMessenger(string key, ILightingScenes device, string messagePath) : base(key, messagePath, device as IKeyName) { @@ -28,11 +38,12 @@ namespace PepperDash.Essentials.AppServer.Messengers PostStatusMessage(state); } + /// protected override void RegisterActions() { base.RegisterActions(); - AddAction("/fullStatus", (id, content) => SendFullStatus()); + AddAction("/fullStatus", (id, content) => SendFullStatus(id)); AddAction("/selectScene", (id, content) => { @@ -40,14 +51,14 @@ namespace PepperDash.Essentials.AppServer.Messengers lightingScenesDevice.SelectScene(s); }); - if(!(lightingScenesDevice is ILightingScenesDynamic lightingScenesDynamic)) + if (!(lightingScenesDevice is ILightingScenesDynamic lightingScenesDynamic)) return; lightingScenesDynamic.LightingScenesUpdated += (s, e) => SendFullStatus(); } - private void SendFullStatus() + private void SendFullStatus(string id = null) { var state = new LightingBaseStateMessage { @@ -55,7 +66,7 @@ namespace PepperDash.Essentials.AppServer.Messengers CurrentLightingScene = lightingScenesDevice.CurrentLightingScene }; - PostStatusMessage(state); + PostStatusMessage(state, id); } } diff --git a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/RoomEventScheduleMessenger.cs b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/RoomEventScheduleMessenger.cs index b8f5feff..580f6bc3 100644 --- a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/RoomEventScheduleMessenger.cs +++ b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/RoomEventScheduleMessenger.cs @@ -1,18 +1,30 @@ -using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using Newtonsoft.Json; using PepperDash.Core; using PepperDash.Core.Logging; using PepperDash.Essentials.Core; using PepperDash.Essentials.Room.Config; -using System; -using System.Collections.Generic; namespace PepperDash.Essentials.AppServer.Messengers { + /// + /// Messenger for managing scheduled events in a room. + /// This class handles saving scheduled events and sending the current schedule state to clients. + /// It listens for changes in the scheduled events and updates clients accordingly. + /// public class RoomEventScheduleMessenger : MessengerBase { private readonly IRoomEventSchedule _room; - + /// + /// Initializes a new instance of the class. + /// This constructor sets up the messenger with a unique key, message path, and the room event schedule interface. + /// It registers actions for saving scheduled events and sending the current schedule state. + /// + /// Unique identifier for the messenger + /// Path for message routing + /// Room event schedule interface public RoomEventScheduleMessenger(string key, string messagePath, IRoomEventSchedule room) : base(key, messagePath, room as IKeyName) { @@ -21,6 +33,7 @@ namespace PepperDash.Essentials.AppServer.Messengers #region Overrides of MessengerBase + /// protected override void RegisterActions() { AddAction("/saveScheduledEvents", (id, content) => SaveScheduledEvents(content.ToObject>())); @@ -28,7 +41,7 @@ namespace PepperDash.Essentials.AppServer.Messengers { var events = _room.GetScheduledEvents(); - SendFullStatus(events); + SendFullStatus(events, id); }); _room.ScheduledEventsChanged += (sender, args) => SendFullStatus(args.ScheduledEvents); @@ -52,11 +65,11 @@ namespace PepperDash.Essentials.AppServer.Messengers } catch (Exception ex) { - this.LogException(ex,"Exception saving event"); + this.LogException(ex, "Exception saving event"); } } - private void SendFullStatus(List events) + private void SendFullStatus(List events, string id = null) { var message = new RoomEventScheduleStateMessage @@ -64,12 +77,22 @@ namespace PepperDash.Essentials.AppServer.Messengers ScheduleEvents = events, }; - PostStatusMessage(message); + PostStatusMessage(message, id); } } + /// + /// Represents the state message for room event schedules. + /// This message contains a list of scheduled events configured for the room. + /// It is used to communicate the current schedule state to clients. + /// public class RoomEventScheduleStateMessage : DeviceStateMessageBase { + /// + /// Gets or sets the list of scheduled events for the room. + /// This property contains the configuration of scheduled events that are set up in the room. + /// Each event includes details such as the event name, start time, end time, and recurrence pattern. + /// [JsonProperty("scheduleEvents")] public List ScheduleEvents { get; set; } } diff --git a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/ShadeBaseMessenger.cs b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/ShadeBaseMessenger.cs index 32d59204..b2afde78 100644 --- a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/ShadeBaseMessenger.cs +++ b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/ShadeBaseMessenger.cs @@ -33,7 +33,7 @@ namespace PepperDash.Essentials.AppServer.Messengers { base.RegisterActions(); - AddAction("/fullStatus", (id, content) => SendFullStatus()); + AddAction("/fullStatus", (id, content) => SendFullStatus(id)); AddAction("/shadeUp", (id, content) => { @@ -86,7 +86,7 @@ namespace PepperDash.Essentials.AppServer.Messengers } - private void SendFullStatus() + private void SendFullStatus(string id = null) { var state = new ShadeBaseStateMessage(); @@ -96,7 +96,7 @@ namespace PepperDash.Essentials.AppServer.Messengers state.IsClosed = feedbackDevice.ShadeIsClosedFeedback.BoolValue; } - PostStatusMessage(state); + PostStatusMessage(state, id); } } diff --git a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/SystemMonitorMessenger.cs b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/SystemMonitorMessenger.cs index a01b9c6c..79238a7a 100644 --- a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/SystemMonitorMessenger.cs +++ b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/SystemMonitorMessenger.cs @@ -64,17 +64,17 @@ namespace PepperDash.Essentials.AppServer.Messengers SendSystemMonitorStatusMessage(); } - private void SendFullStatusMessage() + private void SendFullStatusMessage(string id = null) { - SendSystemMonitorStatusMessage(); + SendSystemMonitorStatusMessage(id); foreach (var p in systemMonitor.ProgramStatusFeedbackCollection) { - PostStatusMessage(JToken.FromObject(p.Value.ProgramInfo)); + PostStatusMessage(JToken.FromObject(p.Value.ProgramInfo), id); } } - private void SendSystemMonitorStatusMessage() + private void SendSystemMonitorStatusMessage(string id = null) { // This takes a while, launch a new thread @@ -87,7 +87,7 @@ namespace PepperDash.Essentials.AppServer.Messengers SnmpVersion = systemMonitor.SnmpVersionFeedback.StringValue, BacnetVersion = systemMonitor.BaCnetAppVersionFeedback.StringValue, ControllerVersion = systemMonitor.ControllerVersionFeedback.StringValue - }) + }), id )); } @@ -97,7 +97,7 @@ namespace PepperDash.Essentials.AppServer.Messengers /// protected override void RegisterActions() { - AddAction("/fullStatus", (id, content) => SendFullStatusMessage()); + AddAction("/fullStatus", (id, content) => SendFullStatusMessage(id)); } } diff --git a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/TwoWayDisplayBaseMessenger.cs b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/TwoWayDisplayBaseMessenger.cs index f0600dd5..f5d0cd85 100644 --- a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/TwoWayDisplayBaseMessenger.cs +++ b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/TwoWayDisplayBaseMessenger.cs @@ -5,10 +5,27 @@ using PepperDash.Essentials.Devices.Common.Displays; namespace PepperDash.Essentials.AppServer.Messengers { + /// + /// Provides messaging capabilities for two-way display control operations. + /// Handles display input changes, power state, and cooling/warming status. + /// This class extends the MessengerBase to facilitate communication between the display and the mobile control interface. + /// public class TwoWayDisplayBaseMessenger : MessengerBase { private readonly TwoWayDisplayBase _display; + /// + /// Initializes a new instance of the class. + /// This constructor sets up the messenger with a key, message path, and the display instance + /// that it will control and monitor. + /// The display instance should implement the TwoWayDisplayBase interface to provide the necessary feedback and + /// control methods for the display device. + /// The messenger will listen for changes in the display's state and send updates to the mobile control interface. + /// It also allows for sending commands to the display, such as changing inputs or toggling power states. + /// + /// The unique identifier for this messenger instance. + /// The message path for display control messages. + /// The display instance to control and monitor. public TwoWayDisplayBaseMessenger(string key, string messagePath, TwoWayDisplayBase display) : base(key, messagePath, display) { @@ -17,7 +34,8 @@ namespace PepperDash.Essentials.AppServer.Messengers #region Overrides of MessengerBase - public void SendFullStatus() + + private void SendFullStatus(string id = null) { var messageObj = new TwoWayDisplayBaseStateMessage { @@ -25,16 +43,20 @@ namespace PepperDash.Essentials.AppServer.Messengers CurrentInput = _display.CurrentInputFeedback.StringValue }; - PostStatusMessage(messageObj); + PostStatusMessage(messageObj, id); } + /// + /// Registers actions for handling two-way display operations. + /// This includes sending full status updates and handling input changes, cooling, and warming feedback. + /// The actions are registered to respond to specific commands sent from the mobile control interface. + /// protected override void RegisterActions() { base.RegisterActions(); - AddAction("/fullStatus", (id, content) => SendFullStatus()); + AddAction("/fullStatus", (id, content) => SendFullStatus(id)); - //_display.PowerIsOnFeedback.OutputChange += PowerIsOnFeedbackOnOutputChange; _display.CurrentInputFeedback.OutputChange += CurrentInputFeedbackOnOutputChange; _display.IsCoolingDownFeedback.OutputChange += IsCoolingFeedbackOnOutputChange; _display.IsWarmingUpFeedback.OutputChange += IsWarmingFeedbackOnOutputChange; @@ -49,16 +71,6 @@ namespace PepperDash.Essentials.AppServer.Messengers ); } - - //private void PowerIsOnFeedbackOnOutputChange(object sender, FeedbackEventArgs feedbackEventArgs) - //{ - // PostStatusMessage(JToken.FromObject(new - // { - // powerState = feedbackEventArgs.BoolValue - // }) - // ); - //} - private void IsWarmingFeedbackOnOutputChange(object sender, FeedbackEventArgs feedbackEventArgs) { PostStatusMessage(JToken.FromObject(new diff --git a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/VideoCodecBaseMessenger.cs b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/VideoCodecBaseMessenger.cs index 16cf642e..d9391152 100644 --- a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/VideoCodecBaseMessenger.cs +++ b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/VideoCodecBaseMessenger.cs @@ -1,4 +1,8 @@ -using Crestron.SimplSharp; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Crestron.SimplSharp; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using PepperDash.Core; @@ -9,9 +13,6 @@ using PepperDash.Essentials.Devices.Common.Cameras; using PepperDash.Essentials.Devices.Common.Codec; using PepperDash.Essentials.Devices.Common.VideoCodec; using PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces; -using System; -using System.Collections.Generic; -using System.Linq; namespace PepperDash.Essentials.AppServer.Messengers { @@ -21,18 +22,18 @@ namespace PepperDash.Essentials.AppServer.Messengers public class VideoCodecBaseMessenger : MessengerBase { /// - /// + /// The video codec device being managed by this messenger. /// protected VideoCodecBase Codec { get; private set; } - /// - /// + /// Initializes a new instance of the class. /// - /// - /// - /// + /// The unique identifier for the messenger. + /// The video codec device to be managed. + /// The message path for communication. + /// Thrown when codec is null public VideoCodecBaseMessenger(string key, VideoCodecBase codec, string messagePath) : base(key, messagePath, codec) { @@ -70,11 +71,6 @@ namespace PepperDash.Essentials.AppServer.Messengers PostEventMessage(eventMsg); } - /// - /// - /// - /// - /// private void CallHistory_RecentCallsListHasChanged(object sender, EventArgs e) { try @@ -98,10 +94,10 @@ namespace PepperDash.Essentials.AppServer.Messengers } /// - /// + /// Handles the event when a directory result is returned from the codec. /// - /// - /// + /// The source of the event. + /// The directory event arguments. protected virtual void DirCodec_DirectoryResultReturned(object sender, DirectoryEventArgs e) { if (Codec is IHasDirectory) @@ -109,8 +105,9 @@ namespace PepperDash.Essentials.AppServer.Messengers } /// - /// Posts the current directory + /// Sends the current directory structure to the mobile control interface. /// + /// The directory structure to send. protected void SendDirectory(CodecDirectory directory) { try @@ -134,11 +131,6 @@ namespace PepperDash.Essentials.AppServer.Messengers } } - /// - /// - /// - /// - /// private void Codec_IsReadyChange(object sender, EventArgs e) { try @@ -151,16 +143,14 @@ namespace PepperDash.Essentials.AppServer.Messengers PostStatusMessage(state); SendFullStatus(); - } catch (Exception ex) + } + catch (Exception ex) { this.LogError(ex, "Error sending codec ready status"); } } - /// - /// Called from base's RegisterWithAppServer method - /// - /// + /// protected override void RegisterActions() { try @@ -169,7 +159,7 @@ namespace PepperDash.Essentials.AppServer.Messengers AddAction("/isReady", (id, content) => SendIsReady()); - AddAction("/fullStatus", (id, content) => SendFullStatus()); + AddAction("/fullStatus", (id, content) => SendFullStatus(id)); AddAction("/dial", (id, content) => { @@ -369,7 +359,8 @@ namespace PepperDash.Essentials.AppServer.Messengers }; PostStatusMessage(state); - } catch (Exception ex) + } + catch (Exception ex) { this.LogError(ex, "Error posting sharing source"); } @@ -385,7 +376,8 @@ namespace PepperDash.Essentials.AppServer.Messengers }; PostStatusMessage(state); - } catch (Exception ex) + } + catch (Exception ex) { this.LogError(ex, "Error posting sharing content"); } @@ -435,15 +427,13 @@ namespace PepperDash.Essentials.AppServer.Messengers { MapCameraActions(); PostSelectedCamera(); - } catch(Exception ex) + } + catch (Exception ex) { this.LogError(ex, "Exception handling camera selected event"); } } - /// - /// Maps the camera control actions to the current selected camera on the codec - /// private void MapCameraActions() { if (Codec is IHasCameras cameraCodec && cameraCodec.SelectedCamera != null) @@ -599,7 +589,7 @@ namespace PepperDash.Essentials.AppServer.Messengers { try { - var codec = (Codec as IHasCallHistory); + var codec = Codec as IHasCallHistory; if (codec != null) { @@ -621,20 +611,11 @@ namespace PepperDash.Essentials.AppServer.Messengers } } - /// - /// Helper to grab a call with string ID - /// - /// - /// private CodecActiveCallItem GetCallWithId(string id) { return Codec.ActiveCalls.FirstOrDefault(c => c.Id == id); } - /// - /// - /// - /// private void GetDirectory(string id) { if (!(Codec is IHasDirectory dirCodec)) @@ -644,10 +625,7 @@ namespace PepperDash.Essentials.AppServer.Messengers dirCodec.GetDirectoryFolderContents(id); } - /// - /// - /// - private void GetDirectoryRoot() + private void GetDirectoryRoot(string id = null) { try { @@ -675,9 +653,6 @@ namespace PepperDash.Essentials.AppServer.Messengers } } - /// - /// Requests the parent folder contents - /// private void GetPreviousDirectory() { if (!(Codec is IHasDirectory dirCodec)) @@ -688,17 +663,11 @@ namespace PepperDash.Essentials.AppServer.Messengers dirCodec.GetDirectoryParentFolderContents(); } - /// - /// Handler for codec changes - /// private void Codec_CallStatusChange(object sender, CodecCallStatusItemChangeEventArgs e) { SendFullStatus(); } - /// - /// - /// private void SendIsReady() { try @@ -719,9 +688,9 @@ namespace PepperDash.Essentials.AppServer.Messengers } /// - /// Helper method to build call status for vtc + /// Gets the current status of the video codec. /// - /// + /// The current status of the video codec. protected VideoCodecBaseStateMessage GetStatus() { try @@ -780,14 +749,18 @@ namespace PepperDash.Essentials.AppServer.Messengers } } - protected virtual void SendFullStatus() + /// + /// Sends the full status of the codec. + /// + /// The unique identifier for the status message. + protected virtual void SendFullStatus(string id = null) { if (!Codec.IsReady) { return; } - CrestronInvoke.BeginInvoke((o) => PostStatusMessage(GetStatus())); + Task.Run(() => PostStatusMessage(GetStatus(), id)); } private void PostReceivingContent(bool receivingContent) @@ -800,7 +773,8 @@ namespace PepperDash.Essentials.AppServer.Messengers }; PostStatusMessage(state); - } catch(Exception ex) + } + catch (Exception ex) { this.LogError(ex, "Error posting receiving content"); } @@ -824,9 +798,6 @@ namespace PepperDash.Essentials.AppServer.Messengers } } - /// - /// - /// private void PostCameraMode() { try @@ -928,164 +899,324 @@ namespace PepperDash.Essentials.AppServer.Messengers public class VideoCodecBaseStateMessage : DeviceStateMessageBase { + /// + /// The list of active calls on the codec. + /// [JsonProperty("calls", NullValueHandling = NullValueHandling.Ignore)] public List Calls { get; set; } + /// + /// The current mode of the camera. + /// [JsonProperty("cameraMode", NullValueHandling = NullValueHandling.Ignore)] public string CameraMode { get; set; } + /// + /// Indicates whether the camera self-view is enabled. + /// [JsonProperty("cameraSelfView", NullValueHandling = NullValueHandling.Ignore)] public bool? CameraSelfViewIsOn { get; set; } + /// + /// Gets the current status of the cameras. + /// [JsonProperty("cameras", NullValueHandling = NullValueHandling.Ignore)] public CameraStatus Cameras { get; set; } + /// + /// Indicates whether the camera supports auto mode. + /// [JsonProperty("cameraSupportsAutoMode", NullValueHandling = NullValueHandling.Ignore)] public bool? CameraSupportsAutoMode { get; set; } + /// + /// Indicates whether the camera supports off mode. + /// [JsonProperty("cameraSupportsOffMode", NullValueHandling = NullValueHandling.Ignore)] public bool? CameraSupportsOffMode { get; set; } + /// + /// The current dial string for the codec. + /// [JsonProperty("currentDialString", NullValueHandling = NullValueHandling.Ignore)] public string CurrentDialString { get; set; } + /// + /// Gets the current directory for the codec. + /// [JsonProperty("currentDirectory", NullValueHandling = NullValueHandling.Ignore)] public CodecDirectory CurrentDirectory { get; set; } + /// + /// Gets the selected folder name in the directory. + /// [JsonProperty("directorySelectedFolderName", NullValueHandling = NullValueHandling.Ignore)] public string DirectorySelectedFolderName { get; set; } + /// + /// Indicates whether the codec has active camera streams. + /// [JsonProperty("hasCameras", NullValueHandling = NullValueHandling.Ignore)] public bool? HasCameras { get; set; } + /// + /// Indicates whether the codec has a directory. + /// [JsonProperty("hasDirectory", NullValueHandling = NullValueHandling.Ignore)] public bool? HasDirectory { get; set; } + /// + /// Indicates whether the codec supports directory search functionality. + /// [JsonProperty("hasDirectorySearch", NullValueHandling = NullValueHandling.Ignore)] public bool? HasDirectorySearch { get; set; } + /// + /// Indicates whether the codec has presets. + /// [JsonProperty("hasPresets", NullValueHandling = NullValueHandling.Ignore)] public bool? HasPresets { get; set; } + /// + /// Indicates whether the codec has recent calls. + /// [JsonProperty("hasRecents", NullValueHandling = NullValueHandling.Ignore)] public bool? HasRecents { get; set; } + /// + /// Indicates whether the initial phonebook sync is complete. + /// [JsonProperty("initialPhonebookSyncComplete", NullValueHandling = NullValueHandling.Ignore)] public bool? InitialPhonebookSyncComplete { get; set; } + /// + /// Gets the information about the video codec. + /// [JsonProperty("info", NullValueHandling = NullValueHandling.Ignore)] public VideoCodecInfo Info { get; set; } + /// + /// Indicates whether the codec is currently in a call. + /// [JsonProperty("isInCall", NullValueHandling = NullValueHandling.Ignore)] public bool? IsInCall { get; set; } + /// + /// Indicates whether the codec is ready. + /// [JsonProperty("isReady", NullValueHandling = NullValueHandling.Ignore)] public bool? IsReady { get; set; } + /// + /// Indicates whether the codec is a Zoom Room. + /// [JsonProperty("isZoomRoom", NullValueHandling = NullValueHandling.Ignore)] public bool? IsZoomRoom { get; set; } + /// + /// Gets the meeting information for the codec, if available. + /// [JsonProperty("meetingInfo", NullValueHandling = NullValueHandling.Ignore)] public MeetingInfo MeetingInfo { get; set; } + /// + /// Gets the list of presets for the codec. + /// [JsonProperty("presets", NullValueHandling = NullValueHandling.Ignore)] public List Presets { get; set; } + /// + /// Indicates whether the privacy mode is currently enabled. + /// [JsonProperty("privacyModeIsOn", NullValueHandling = NullValueHandling.Ignore)] public bool? PrivacyModeIsOn { get; set; } + /// + /// Indicates whether the codec is currently receiving content. + /// [JsonProperty("receivingContent", NullValueHandling = NullValueHandling.Ignore)] public bool? ReceivingContent { get; set; } + /// + /// Gets the list of recent calls for the codec, if available. + /// [JsonProperty("recentCalls", NullValueHandling = NullValueHandling.Ignore)] public List RecentCalls { get; set; } + /// + /// Indicates whether the codec is currently sharing content. + /// [JsonProperty("sharingContentIsOn", NullValueHandling = NullValueHandling.Ignore)] public bool? SharingContentIsOn { get; set; } + /// + /// Gets the source of the shared content, if available. + /// [JsonProperty("sharingSource", NullValueHandling = NullValueHandling.Ignore)] public string SharingSource { get; set; } + /// + /// Indicates whether the cameras should be shown when not in a call. + /// [JsonProperty("showCamerasWhenNotInCall", NullValueHandling = NullValueHandling.Ignore)] public bool? ShowCamerasWhenNotInCall { get; set; } + /// + /// Indicates whether the self-view is shown by default. + /// [JsonProperty("showSelfViewByDefault", NullValueHandling = NullValueHandling.Ignore)] public bool? ShowSelfViewByDefault { get; set; } + /// + /// Indicates whether the codec is currently in standby mode. + /// [JsonProperty("standbyIsOn", NullValueHandling = NullValueHandling.Ignore)] public bool? StandbyIsOn { get; set; } + /// + /// Indicates whether the codec supports ad-hoc meetings. + /// [JsonProperty("supportsAdHocMeeting", NullValueHandling = NullValueHandling.Ignore)] public bool? SupportsAdHocMeeting { get; set; } } + /// + /// Represents the status of the camera. + /// public class CameraStatus { + /// + /// Indicates whether the camera manual control is supported. + /// [JsonProperty("cameraManualSupported", NullValueHandling = NullValueHandling.Ignore)] public bool? CameraManualIsSupported { get; set; } + /// + /// Indicates whether the camera auto control is supported. + /// [JsonProperty("cameraAutoSupported", NullValueHandling = NullValueHandling.Ignore)] public bool? CameraAutoIsSupported { get; set; } + /// + /// Indicates whether the camera off control is supported. + /// [JsonProperty("cameraOffSupported", NullValueHandling = NullValueHandling.Ignore)] public bool? CameraOffIsSupported { get; set; } + /// + /// Indicates the current mode of the camera. + /// [JsonProperty("cameraMode", NullValueHandling = NullValueHandling.Ignore)] public string CameraMode { get; set; } + /// + /// Represents the list of cameras available. + /// [JsonProperty("cameraList", NullValueHandling = NullValueHandling.Ignore)] public List Cameras { get; set; } + /// + /// Represents the currently selected camera. + /// [JsonProperty("selectedCamera", NullValueHandling = NullValueHandling.Ignore)] - public Camera SelectedCamera { get; set; } + public Camera SelectedCamera { get; set; } } + /// + /// Represents a camera in the video codec system. + /// public class Camera { + /// + /// The unique identifier for the camera. + /// [JsonProperty("key", NullValueHandling = NullValueHandling.Ignore)] public string Key { get; set; } + /// + /// The name of the camera. + /// [JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)] public string Name { get; set; } + /// + /// Indicates whether the camera is a far-end camera. + /// [JsonProperty("isFarEnd", NullValueHandling = NullValueHandling.Ignore)] public bool? IsFarEnd { get; set; } + /// + /// Represents the capabilities of the camera. + /// [JsonProperty("capabilities", NullValueHandling = NullValueHandling.Ignore)] public CameraCapabilities Capabilities { get; set; } } + /// + /// Represents the capabilities of the camera. + /// public class CameraCapabilities { + /// + /// Indicates whether the camera can pan. + /// [JsonProperty("canPan", NullValueHandling = NullValueHandling.Ignore)] public bool? CanPan { get; set; } + /// + /// Indicates whether the camera can tilt. + /// [JsonProperty("canTilt", NullValueHandling = NullValueHandling.Ignore)] public bool? CanTilt { get; set; } + /// + /// Indicates whether the camera can zoom. + /// [JsonProperty("canZoom", NullValueHandling = NullValueHandling.Ignore)] public bool? CanZoom { get; set; } + /// + /// Indicates whether the camera can focus. + /// [JsonProperty("canFocus", NullValueHandling = NullValueHandling.Ignore)] public bool? CanFocus { get; set; } } + /// + /// Represents a video codec event message. + /// public class VideoCodecBaseEventMessage : DeviceEventMessageBase { } + /// + /// Represents a password prompt event message. + /// public class PasswordPromptEventMessage : VideoCodecBaseEventMessage { + /// + /// The message to display in the password prompt. + /// [JsonProperty("message", NullValueHandling = NullValueHandling.Ignore)] public string Message { get; set; } + + /// + /// Indicates whether the last password attempt was incorrect. + /// [JsonProperty("lastAttemptWasIncorrect", NullValueHandling = NullValueHandling.Ignore)] public bool LastAttemptWasIncorrect { get; set; } + /// + /// Indicates whether the login attempt failed. + /// [JsonProperty("loginAttemptFailed", NullValueHandling = NullValueHandling.Ignore)] public bool LoginAttemptFailed { get; set; } + /// + /// Indicates whether the login attempt was cancelled. + /// [JsonProperty("loginAttemptCancelled", NullValueHandling = NullValueHandling.Ignore)] public bool LoginAttemptCancelled { get; set; } }