mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-08 01:04:56 +00:00
feat: move MC into Essentials
In order to solve some dependency issues that keep cropping up, MC should be moved back into the Essentials repo and loaded automatically on startup. This will allow for all plugins that use the MC Messengers library to use the same version without fear of overwriting a dll due to loading of plugin libraries.
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.AppServer.Messengers;
|
||||
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
|
||||
|
||||
namespace PepperDash.Essentials.Touchpanel
|
||||
{
|
||||
public class ITswAppControlMessenger : MessengerBase
|
||||
{
|
||||
private readonly ITswAppControl _appControl;
|
||||
|
||||
public ITswAppControlMessenger(string key, string messagePath, Device device) : base(key, messagePath, device)
|
||||
{
|
||||
_appControl = device as ITswAppControl;
|
||||
}
|
||||
|
||||
protected override void RegisterActions()
|
||||
{
|
||||
if (_appControl == null)
|
||||
{
|
||||
Debug.Console(0, this, $"{_device.Key} does not implement ITswAppControl");
|
||||
return;
|
||||
}
|
||||
|
||||
AddAction($"/fullStatus", (id, context) => SendFullStatus());
|
||||
|
||||
AddAction($"/openApp", (id, context) => _appControl.OpenApp());
|
||||
|
||||
AddAction($"/closeApp", (id, context) => _appControl.CloseOpenApp());
|
||||
|
||||
AddAction($"/hideApp", (id, context) => _appControl.HideOpenApp());
|
||||
|
||||
_appControl.AppOpenFeedback.OutputChange += (s, a) =>
|
||||
{
|
||||
PostStatusMessage(JToken.FromObject(new
|
||||
{
|
||||
appOpen = a.BoolValue
|
||||
}));
|
||||
};
|
||||
}
|
||||
|
||||
private void SendFullStatus()
|
||||
{
|
||||
var message = new TswAppStateMessage
|
||||
{
|
||||
AppOpen = _appControl.AppOpenFeedback.BoolValue,
|
||||
};
|
||||
|
||||
PostStatusMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
public class TswAppStateMessage : DeviceStateMessageBase
|
||||
{
|
||||
[JsonProperty("appOpen", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public bool? AppOpen { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user