mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-01-11 19:44:52 +00:00
feat: adds IBasicVideoMuteWithFeedbackMessenger
This commit is contained in:
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a IBasicVideoMuteWithFeedbackMessenger
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SendFullStatus method
|
||||
/// </summary>
|
||||
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
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a IBasicVideoMuteWithFeedbackMessage
|
||||
/// </summary>
|
||||
public class IBasicVideoMuteWithFeedbackMessage : DeviceStateMessageBase
|
||||
{
|
||||
[JsonProperty("videoMuteState")]
|
||||
public bool VideoMuteState { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user