mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-10 10:15:01 +00:00
UI Applications can now request status for specific feature sets instead of full status for a device. This will hopefully cut down on the traffic and messages required to get the data for the UI.
87 lines
2.5 KiB
C#
87 lines
2.5 KiB
C#
using System.Collections.Generic;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using PepperDash.Core;
|
|
using PepperDash.Essentials.Core;
|
|
|
|
namespace PepperDash.Essentials.AppServer.Messengers
|
|
{
|
|
/// <summary>
|
|
/// Represents a IBasicVideoMuteWithFeedbackMessenger
|
|
/// </summary>
|
|
public class IBasicVideoMuteWithFeedbackMessenger : MessengerBase
|
|
{
|
|
private readonly IBasicVideoMuteWithFeedback device;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="IBasicVideoMuteWithFeedbackMessenger"/> class.
|
|
/// </summary>
|
|
/// <param name="key"></param>
|
|
/// <param name="messagePath"></param>
|
|
/// <param name="device"></param>
|
|
public IBasicVideoMuteWithFeedbackMessenger(string key, string messagePath, IBasicVideoMuteWithFeedback device)
|
|
: base(key, messagePath, device as IKeyName)
|
|
{
|
|
this.device = device;
|
|
}
|
|
|
|
/// <summary>
|
|
/// SendFullStatus method
|
|
/// </summary>
|
|
public void SendFullStatus(string id = null)
|
|
{
|
|
var messageObj = new IBasicVideoMuteWithFeedbackMessage
|
|
{
|
|
VideoMuteState = device.VideoMuteIsOn.BoolValue
|
|
};
|
|
|
|
PostStatusMessage(messageObj, id);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void RegisterActions()
|
|
{
|
|
base.RegisterActions();
|
|
|
|
AddAction("/fullStatus", (id, content) => SendFullStatus(id));
|
|
|
|
AddAction("/videoMuteStatus", (id, content) => SendFullStatus(id));
|
|
|
|
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; }
|
|
}
|
|
}
|