mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-01 22:04:52 +00:00
Moved messaging for new types to specifc type messengers and tested.
This commit is contained in:
@@ -132,17 +132,17 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
||||
{
|
||||
var presetsCamera = Camera as IHasCameraPresets;
|
||||
|
||||
var presets = new List<CameraPreset>();
|
||||
var presetList = new List<CameraPreset>();
|
||||
|
||||
if (presetsCamera != null)
|
||||
presets = presetsCamera.Presets;
|
||||
presetList = presetsCamera.Presets;
|
||||
|
||||
var info = new
|
||||
PostStatusMessage(new
|
||||
{
|
||||
cameraMode = GetCameraMode(),
|
||||
hasPresets = Camera as IHasCameraPresets,
|
||||
presets = presets
|
||||
};
|
||||
hasPresets = Camera is IHasCameraPresets,
|
||||
presets = presetList
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace PepperDash.Essentials.AppServer.Messengers
|
||||
{
|
||||
public class IRunRouteActionMessenger : MessengerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Device being bridged
|
||||
/// </summary>
|
||||
public IRunRouteAction RoutingDevice {get; set;}
|
||||
|
||||
public IRunRouteActionMessenger(string key, IRunRouteAction routingDevice, string messagePath)
|
||||
: base(key, messagePath)
|
||||
{
|
||||
if (routingDevice == null)
|
||||
throw new ArgumentNullException("routingDevice");
|
||||
|
||||
RoutingDevice = routingDevice;
|
||||
|
||||
var routingSink = RoutingDevice as IRoutingSinkNoSwitching;
|
||||
|
||||
if (routingSink != null)
|
||||
{
|
||||
routingSink.CurrentSourceChange += new SourceInfoChangeHandler(routingSink_CurrentSourceChange);
|
||||
}
|
||||
}
|
||||
|
||||
void routingSink_CurrentSourceChange(SourceListItem info, ChangeType type)
|
||||
{
|
||||
SendRoutingFullMessageObject();
|
||||
}
|
||||
|
||||
protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
|
||||
{
|
||||
appServerController.AddAction(MessagePath + "/fullStatus", new Action(SendRoutingFullMessageObject));
|
||||
|
||||
appServerController.AddAction(string.Format(@"/device/inRoomPc-1/source"), new Action<SourceSelectMessageContent>(c =>
|
||||
{
|
||||
RoutingDevice.RunRouteAction(c.SourceListItem, c.SourceListKey);
|
||||
}));
|
||||
|
||||
var sinkDevice = RoutingDevice as IRoutingSinkNoSwitching;
|
||||
if(sinkDevice != null)
|
||||
{
|
||||
sinkDevice.CurrentSourceChange += new SourceInfoChangeHandler((o, a) =>
|
||||
{
|
||||
SendRoutingFullMessageObject();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method to update full status of the routing device
|
||||
/// </summary>
|
||||
void SendRoutingFullMessageObject()
|
||||
{
|
||||
var sinkDevice = RoutingDevice as IRoutingSinkNoSwitching;
|
||||
|
||||
if(sinkDevice != null)
|
||||
{
|
||||
var sourceKey = sinkDevice.CurrentSourceInfoKey;
|
||||
|
||||
if (string.IsNullOrEmpty(sourceKey))
|
||||
sourceKey = "none";
|
||||
|
||||
PostStatusMessage(new
|
||||
{
|
||||
selectedSourceKey = sourceKey
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,36 +78,6 @@ namespace PepperDash.Essentials
|
||||
}
|
||||
}));
|
||||
|
||||
//****************Temp until testing complete. Then move to own messenger***********************
|
||||
|
||||
var routeDevice = DeviceManager.GetDeviceForKey("inRoomPc-1") as IRunRouteAction;
|
||||
if (routeDevice != null)
|
||||
{
|
||||
Parent.AddAction(string.Format(@"/device/inRoomPc-1/source"), new Action<SourceSelectMessageContent>(c =>
|
||||
{
|
||||
routeDevice.RunRouteAction(c.SourceListItem, c.SourceListKey);
|
||||
}));
|
||||
|
||||
var sinkDevice = routeDevice as IRoutingSinkNoSwitching;
|
||||
if(sinkDevice != null)
|
||||
{
|
||||
sinkDevice.CurrentSourceChange += new SourceInfoChangeHandler((o, a) =>
|
||||
{
|
||||
var contentObject = new
|
||||
{
|
||||
selectedSourceKey = sinkDevice.CurrentSourceInfoKey
|
||||
};
|
||||
|
||||
Parent.SendMessageToServer(JObject.FromObject(new
|
||||
{
|
||||
type = "/device/inRoomPc-1/status",
|
||||
content = contentObject
|
||||
}));
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var defaultRoom = Room as IRunDefaultPresentRoute;
|
||||
if(defaultRoom != null)
|
||||
@@ -190,9 +160,18 @@ namespace PepperDash.Essentials
|
||||
if (device is Essentials.Devices.Common.Cameras.CameraBase)
|
||||
{
|
||||
var camDevice = device as Essentials.Devices.Common.Cameras.CameraBase;
|
||||
var devKey = device.Key;
|
||||
Debug.Console(2, this, "Adding CameraBaseMessenger for device: {0}", devKey);
|
||||
DeviceMessengers.Add(devKey, new CameraBaseMessenger(devKey + "-" + Parent.Key, camDevice, "/device/" + devKey));
|
||||
Debug.Console(2, this, "Adding CameraBaseMessenger for device: {0}", device.Key);
|
||||
var cameraMessenger = new CameraBaseMessenger(device.Key + "-" + Parent.Key, camDevice, "/device/" + device.Key);
|
||||
DeviceMessengers.Add(device.Key, cameraMessenger);
|
||||
cameraMessenger.RegisterWithAppServer(Parent);
|
||||
}
|
||||
if (device is Essentials.Devices.Common.SoftCodec.BlueJeansPc)
|
||||
{
|
||||
var softCodecDevice = device as Essentials.Devices.Common.SoftCodec.BlueJeansPc;
|
||||
Debug.Console(2, this, "Adding IRunRouteActionMessnger for device: {0}", device.Key);
|
||||
var routeMessenger = new IRunRouteActionMessenger(device.Key + "-" + Parent.Key, softCodecDevice, "/device/" + device.Key);
|
||||
DeviceMessengers.Add(device.Key, routeMessenger);
|
||||
routeMessenger.RegisterWithAppServer(Parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,6 +113,7 @@
|
||||
<Compile Include="AppServer\Messengers\Ddvc01AtcMessenger.cs" />
|
||||
<Compile Include="AppServer\Messengers\AudioCodecBaseMessenger.cs" />
|
||||
<Compile Include="AppServer\Messengers\Ddvc01VtcMessenger.cs" />
|
||||
<Compile Include="AppServer\Messengers\IRunRouteActionMessenger.cs" />
|
||||
<Compile Include="AppServer\Messengers\MessengerBase.cs" />
|
||||
<Compile Include="AppServer\Messengers\SystemMonitorMessenger.cs" />
|
||||
<Compile Include="AppServer\Messengers\VideoCodecBaseMessenger.cs" />
|
||||
|
||||
Reference in New Issue
Block a user