From 8cf195b262816cec40d4d7aef239c3d5e8cf8ad0 Mon Sep 17 00:00:00 2001 From: aknous Date: Tue, 19 Aug 2025 11:37:39 -0400 Subject: [PATCH] feat: adds IBasicVideoMuteWithFeedbackMessenger --- .../IBasicVideoMuteWithFeedbackMessenger.cs | 77 +++++++++++++++++++ .../MobileControlSystemController.cs | 19 +++++ 2 files changed, 96 insertions(+) create mode 100644 src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IBasicVideoMuteWithFeedbackMessenger.cs diff --git a/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IBasicVideoMuteWithFeedbackMessenger.cs b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IBasicVideoMuteWithFeedbackMessenger.cs new file mode 100644 index 00000000..70d59aa4 --- /dev/null +++ b/src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IBasicVideoMuteWithFeedbackMessenger.cs @@ -0,0 +1,77 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using System.Collections.Generic; + +namespace PepperDash.Essentials.AppServer.Messengers +{ + /// + /// Represents a IBasicVideoMuteWithFeedbackMessenger + /// + public class IBasicVideoMuteWithFeedbackMessenger : MessengerBase + { + private readonly IBasicVideoMuteWithFeedback device; + + public IBasicVideoMuteWithFeedbackMessenger(string key, string messagePath, IBasicVideoMuteWithFeedback device) + : base(key, messagePath, device as IKeyName) + { + this.device = device; + } + + /// + /// SendFullStatus method + /// + public void SendFullStatus() + { + var messageObj = new IBasicVideoMuteWithFeedbackMessage + { + VideoMuteState = device.VideoMuteIsOn.BoolValue + }; + + PostStatusMessage(messageObj); + } + + protected override void RegisterActions() + { + base.RegisterActions(); + + AddAction("/fullStatus", (id, content) => SendFullStatus()); + + AddAction("/videoMuteToggle", (id, content) => + { + device.VideoMuteToggle(); + }); + + AddAction("/videoMuteOn", (id, content) => + { + device.VideoMuteOn(); + }); + + AddAction("/videoMuteOff", (id, content) => + { + device.VideoMuteOff(); + }); + + device.VideoMuteIsOn.OutputChange += VideoMuteIsOnFeedback_OutputChange; + } + + private void VideoMuteIsOnFeedback_OutputChange(object sender, FeedbackEventArgs args) + { + PostStatusMessage(JToken.FromObject(new + { + videoMuteState = args.BoolValue + }) + ); + } + } + + /// + /// Represents a IBasicVideoMuteWithFeedbackMessage + /// + public class IBasicVideoMuteWithFeedbackMessage : DeviceStateMessageBase + { + [JsonProperty("videoMuteState")] + public bool VideoMuteState { get; set; } + } +} diff --git a/src/PepperDash.Essentials.MobileControl/MobileControlSystemController.cs b/src/PepperDash.Essentials.MobileControl/MobileControlSystemController.cs index f5854516..49e71010 100644 --- a/src/PepperDash.Essentials.MobileControl/MobileControlSystemController.cs +++ b/src/PepperDash.Essentials.MobileControl/MobileControlSystemController.cs @@ -505,6 +505,25 @@ namespace PepperDash.Essentials messengerAdded = true; } + if (device is IBasicVideoMuteWithFeedback) + { + var deviceKey = device.Key; + this.LogVerbose( + "Adding IBasicVideoMuteWithFeedback for {deviceKey}", + deviceKey + ); + + var videoMuteControlDevice = device as IBasicVideoMuteWithFeedback; + var messenger = new IBasicVideoMuteWithFeedbackMessenger( + $"{device.Key}-videoMute-{Key}", + string.Format("/device/{0}", deviceKey), + videoMuteControlDevice + ); + AddDefaultDeviceMessenger(messenger); + + messengerAdded = true; + } + if (device is ILightingScenes || device is LightingBase) { var deviceKey = device.Key;