mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-14 12:15:01 +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,73 @@
|
||||
using Newtonsoft.Json;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
|
||||
using PepperDash.Essentials.Core.Lighting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace PepperDash.Essentials.AppServer.Messengers
|
||||
{
|
||||
public class ILightingScenesMessenger : MessengerBase
|
||||
{
|
||||
protected ILightingScenes Device { get; private set; }
|
||||
|
||||
public ILightingScenesMessenger(string key, ILightingScenes device, string messagePath)
|
||||
: base(key, messagePath, device as Device)
|
||||
{
|
||||
Device = device ?? throw new ArgumentNullException("device");
|
||||
Device.LightingSceneChange += new EventHandler<LightingSceneChangeEventArgs>(LightingDevice_LightingSceneChange);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void LightingDevice_LightingSceneChange(object sender, LightingSceneChangeEventArgs e)
|
||||
{
|
||||
var state = new LightingBaseStateMessage
|
||||
{
|
||||
CurrentLightingScene = e.CurrentLightingScene
|
||||
};
|
||||
|
||||
PostStatusMessage(state);
|
||||
}
|
||||
|
||||
#if SERIES4
|
||||
protected override void RegisterActions()
|
||||
#else
|
||||
protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
|
||||
#endif
|
||||
{
|
||||
base.RegisterActions();
|
||||
|
||||
AddAction("/fullStatus", (id, content) => SendFullStatus());
|
||||
|
||||
AddAction("/selectScene", (id, content) =>
|
||||
{
|
||||
var s = content.ToObject<LightingScene>();
|
||||
Device.SelectScene(s);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void SendFullStatus()
|
||||
{
|
||||
Debug.Console(2, "LightingBaseMessenger GetFullStatus");
|
||||
|
||||
var state = new LightingBaseStateMessage
|
||||
{
|
||||
Scenes = Device.LightingScenes,
|
||||
CurrentLightingScene = Device.CurrentLightingScene
|
||||
};
|
||||
|
||||
PostStatusMessage(state);
|
||||
}
|
||||
}
|
||||
|
||||
public class LightingBaseStateMessage : DeviceStateMessageBase
|
||||
{
|
||||
[JsonProperty("scenes", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public List<LightingScene> Scenes { get; set; }
|
||||
|
||||
[JsonProperty("currentLightingScene", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public LightingScene CurrentLightingScene { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user