Adds CustomUnregisterWithAppServer method to allow unregistration at runtime

This commit is contained in:
Neil Dorin
2019-12-10 14:28:20 -07:00
parent 5819ac78ec
commit c54351f8ee
3 changed files with 32 additions and 7 deletions

View File

@@ -109,10 +109,11 @@ namespace PepperDash.Essentials.AppServer.Messengers
{
var asc = appServerController;
asc.AddAction(MessagePath + "/fullStatus", new Action(SendCameraFullMessageObject));
// Add press and holds using helper action
Action<string, uint> addPHAction = (s, u) =>
AppServerController.AddAction(MessagePath + s, new PressAndHoldAction(b => EISC.SetBool(u, b)));
asc.AddAction(MessagePath + s, new PressAndHoldAction(b => EISC.SetBool(u, b)));
addPHAction("/cameraUp", BoolJoin.CameraControlUp + JoinStart);
addPHAction("/cameraDown", BoolJoin.CameraControlDown + JoinStart);
addPHAction("/cameraLeft", BoolJoin.CameraControlLeft + JoinStart);
@@ -121,7 +122,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
addPHAction("/cameraZoomOut", BoolJoin.CameraControlZoomOut + JoinStart);
Action<string, uint> addAction = (s, u) =>
AppServerController.AddAction(MessagePath + s, new Action(() => EISC.PulseBool(u, 100)));
asc.AddAction(MessagePath + s, new Action(() => EISC.PulseBool(u, 100)));
addAction("/cameraModeAuto", BoolJoin.CameraModeAuto);
addAction("/cameraModeManual", BoolJoin.CameraModeManual);
@@ -132,10 +133,27 @@ namespace PepperDash.Essentials.AppServer.Messengers
{
addAction("/cameraPreset" + (i), BoolJoin.CameraPresetStart + i + JoinStart);
}
}
asc.AddAction(MessagePath + "/fullStatus", new Action(SendCameraFullMessageObject));
public void CustomUnregsiterWithAppServer(MobileControlSystemController appServerController)
{
appServerController.RemoveAction(MessagePath + "/fullStatus");
appServerController.RemoveAction(MessagePath + "/cameraUp");
appServerController.RemoveAction(MessagePath + "/cameraDown");
appServerController.RemoveAction(MessagePath + "/cameraLeft");
appServerController.RemoveAction(MessagePath + "/cameraRight");
appServerController.RemoveAction(MessagePath + "/cameraZoomIn");
appServerController.RemoveAction(MessagePath + "/cameraZoomOut");
appServerController.RemoveAction(MessagePath + "/cameraModeAuto");
appServerController.RemoveAction(MessagePath + "/cameraModeManual");
appServerController.RemoveAction(MessagePath + "/cameraModeOff");
EISC.SetUShortSigAction(UshortJoin.CameraPresetCount + JoinStart, null);
EISC.SetBoolSigAction(BoolJoin.CameraModeAuto, null);
EISC.SetBoolSigAction(BoolJoin.CameraModeManual, null);
EISC.SetBoolSigAction(BoolJoin.CameraModeOff, null);
}
/// <summary>

View File

@@ -34,7 +34,6 @@ namespace PepperDash.Essentials.AppServer.Messengers
EISC.SetStringSigAction(JoinStart + StringJoin.CurrentSource, (s) => SendRoutingFullMessageObject(s));
}
protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
{
appServerController.AddAction(MessagePath + "/fullStatus", new Action(() =>
@@ -42,13 +41,21 @@ namespace PepperDash.Essentials.AppServer.Messengers
SendRoutingFullMessageObject(EISC.GetString(JoinStart + StringJoin.CurrentSource));
}));
appServerController.AddAction(string.Format(@"/device/inRoomPc-1/source"), new Action<SourceSelectMessageContent>(c =>
appServerController.AddAction(MessagePath +"/source", new Action<SourceSelectMessageContent>(c =>
{
EISC.SetString(JoinStart + StringJoin.CurrentSource, c.SourceListItem);
}));
}
public void CustomUnregsiterWithAppServer(MobileControlSystemController appServerController)
{
appServerController.RemoveAction(MessagePath + "/fullStatus");
appServerController.RemoveAction(MessagePath + "/source");
EISC.SetStringSigAction(JoinStart + StringJoin.CurrentSource, null);
}
/// <summary>
/// Helper method to update full status of the routing device
/// </summary>

View File

@@ -776,13 +776,12 @@ namespace PepperDash.Essentials.Room.MobileControl
{
foreach (var device in ConfigReader.ConfigObject.Devices)
{
if (device.Group.Equals("appServerMessenger"))
if (device.Group.Equals("simplmessenger"))
{
var props = JsonConvert.DeserializeObject<SimplMessengerPropertiesConfig>(device.Properties.ToString());
var messengerKey = string.Format("device-{0}-{1}", this.Key, Parent.Key);
MessengerBase messenger = null;
var dev = ConfigReader.ConfigObject.GetDeviceForKey(props.DeviceKey);
@@ -793,6 +792,7 @@ namespace PepperDash.Essentials.Room.MobileControl
}
var type = device.Type.ToLower();
MessengerBase messenger = null;
if (type.Equals("simplcameramessenger"))
{