diff --git a/PepperDashEssentials/AppServer/Messengers/MessengerBase.cs b/PepperDashEssentials/AppServer/Messengers/MessengerBase.cs
new file mode 100644
index 00000000..125bf83a
--- /dev/null
+++ b/PepperDashEssentials/AppServer/Messengers/MessengerBase.cs
@@ -0,0 +1,72 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Crestron.SimplSharp;
+
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+
+using PepperDash.Essentials.Devices.Common.Codec;
+using PepperDash.Essentials.Devices.Common.VideoCodec;
+
+namespace PepperDash.Essentials.AppServer.Messengers
+{
+ ///
+ /// Provides a messaging bridge for a VideoCodecBase
+ ///
+ public abstract class MessengerBase
+ {
+ ///
+ ///
+ ///
+ public CotijaSystemController AppServerController { get; private set; }
+
+ public string MessagePath { get; private set; }
+
+ ///
+ ///
+ ///
+ ///
+ public MessengerBase(string messagePath)
+ {
+ if (string.IsNullOrEmpty(messagePath))
+ throw new ArgumentException("messagePath must not be empty or null");
+
+ MessagePath = messagePath;
+ }
+
+
+ ///
+ /// Registers this messenger with appserver controller
+ ///
+ ///
+ public void RegisterWithAppServer(CotijaSystemController appServerController)
+ {
+ if (appServerController == null)
+ throw new ArgumentNullException("appServerController");
+
+ AppServerController = appServerController;
+ CustomRegisterWithAppServer(AppServerController);
+ }
+
+ ///
+ /// Implemented in extending classes. Wire up API calls and feedback here
+ ///
+ ///
+ abstract protected void CustomRegisterWithAppServer(CotijaSystemController appServerController);
+
+ ///
+ /// Helper for posting status message
+ ///
+ /// The contents of the content object
+ protected void PostStatusMessage(object contentObject)
+ {
+ AppServerController.SendMessageToServer(JObject.FromObject(new
+ {
+ type = MessagePath,
+ content = contentObject
+ }));
+ }
+ }
+}
\ No newline at end of file
diff --git a/PepperDashEssentials/AppServer/Messengers/VideoCodecBaseMessenger.cs b/PepperDashEssentials/AppServer/Messengers/VideoCodecBaseMessenger.cs
index 67180b35..37437b5d 100644
--- a/PepperDashEssentials/AppServer/Messengers/VideoCodecBaseMessenger.cs
+++ b/PepperDashEssentials/AppServer/Messengers/VideoCodecBaseMessenger.cs
@@ -15,29 +15,22 @@ namespace PepperDash.Essentials.AppServer.Messengers
///
/// Provides a messaging bridge for a VideoCodecBase
///
- public class VideoCodecBaseMessenger
+ public class VideoCodecBaseMessenger : MessengerBase
{
///
///
///
public VideoCodecBase Codec { get; private set; }
- public CotijaSystemController AppServerController { get; private set; }
-
- public string MessagePath { get; private set; }
-
///
///
///
///
- public VideoCodecBaseMessenger(VideoCodecBase codec, string messagePath)
+ public VideoCodecBaseMessenger(VideoCodecBase codec, string messagePath) : base(messagePath)
{
if (codec == null)
throw new ArgumentNullException("codec");
- if (string.IsNullOrEmpty(messagePath))
- throw new ArgumentException("messagePath must not be empty or null");
- MessagePath = messagePath;
Codec = codec;
codec.CallStatusChange += new EventHandler(codec_CallStatusChange);
codec.IsReadyChange += new EventHandler(codec_IsReadyChange);
@@ -77,16 +70,11 @@ namespace PepperDash.Essentials.AppServer.Messengers
}
///
- /// Registers this codec's messaging with an app server controller
+ /// Called from base's RegisterWithAppServer method
///
///
- public void RegisterWithAppServer(CotijaSystemController appServerController)
+ protected override void CustomRegisterWithAppServer(CotijaSystemController appServerController)
{
- if (appServerController == null)
- throw new ArgumentNullException("appServerController");
-
- AppServerController = appServerController;
-
appServerController.AddAction("/device/videoCodec/isReady", new Action(SendIsReady));
appServerController.AddAction("/device/videoCodec/fullStatus", new Action(SendVtcFullMessageObject));
appServerController.AddAction("/device/videoCodec/dial", new Action(s => Codec.Dial(s)));
@@ -242,18 +230,5 @@ namespace PepperDash.Essentials.AppServer.Messengers
hasDirectory = Codec is IHasDirectory
});
}
-
- ///
- /// Helper for posting status message
- ///
- /// The contents of the content object
- void PostStatusMessage(object contentObject)
- {
- AppServerController.SendMessageToServer(JObject.FromObject(new
- {
- type = MessagePath,
- content = contentObject
- }));
- }
}
}
\ No newline at end of file
diff --git a/PepperDashEssentials/PepperDashEssentials.csproj b/PepperDashEssentials/PepperDashEssentials.csproj
index 14e916f9..1bcd3259 100644
--- a/PepperDashEssentials/PepperDashEssentials.csproj
+++ b/PepperDashEssentials/PepperDashEssentials.csproj
@@ -104,6 +104,7 @@
+