diff --git a/PepperDashEssentials/AppServer/CotijaSystemController.cs b/PepperDashEssentials/AppServer/CotijaSystemController.cs
index f72857d1..a6b06e55 100644
--- a/PepperDashEssentials/AppServer/CotijaSystemController.cs
+++ b/PepperDashEssentials/AppServer/CotijaSystemController.cs
@@ -239,6 +239,7 @@ namespace PepperDash.Essentials
if (r.Code == 200)
{
Debug.Console(0, "System authorized, sending config.");
+#warning This registration may need to wait for config ready. Maybe.
RegisterSystemToServer();
}
else if (r.Code == 404)
@@ -301,102 +302,8 @@ namespace PepperDash.Essentials
{
ConnectWebsocketClient();
return;
-
- //var ready = RegisterLockEvent.Wait(20000);
- //if (!ready)
- //{
- // Debug.Console(1, this, "RegisterSystemToServer event failed to clear after 20 seconds. Ignoring");
- // //return;
- //}
- //RegisterLockEvent.Reset();
-
- //try
- //{
- // var confObject = ConfigReader.ConfigObject;
- // confObject.Info.RuntimeInfo.AppName = Assembly.GetExecutingAssembly().GetName().Name;
- // var version = Assembly.GetExecutingAssembly().GetName().Version;
- // confObject.Info.RuntimeInfo.AssemblyVersion = string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Build);
-
- // string postBody = JsonConvert.SerializeObject(confObject);
- // SystemUuid = confObject.SystemUuid;
-
- // if (string.IsNullOrEmpty(postBody))
- // {
- // Debug.Console(1, this, "ERROR: Config body is empty. Cannot register with server.");
- // }
- // else
- // {
- // var regClient = new HttpClient();
- // regClient.Verbose = true;
- // regClient.KeepAlive = true;
-
- // string url = string.Format("http://{0}/api/system/join/{1}", Config.ServerUrl, SystemUuid);
- // Debug.Console(1, this, "Joining server at {0}", url);
-
- // HttpClientRequest request = new HttpClientRequest();
- // request.Url.Parse(url);
- // request.RequestType = RequestType.Post;
- // request.Header.SetHeaderValue("Content-Type", "application/json");
- // request.ContentString = postBody;
-
- // regClient.DispatchAsync(request, RegistrationConnectionCallback);
- // }
-
- //}
- //catch (Exception e)
- //{
- // Debug.Console(0, this, "ERROR: Initilizing app server controller: {0}", e);
- // RegisterLockEvent.Set();
- // StartReconnectTimer();
- //}
-
}
- /////
- ///// The callback that fires when we get a response from our registration attempt
- /////
- /////
- /////
- //void RegistrationConnectionCallback(HttpClientResponse resp, HTTP_CALLBACK_ERROR err)
- //{
- // CheckHttpDebug(resp, err);
- // try
- // {
- // if (resp != null && resp.Code == 200)
- // {
- // StopReconnectTimer();
-
- // // Success here!
- // ConnectStreamClient();
- // }
- // else
- // {
- // if (resp != null)
- // {
- // if (resp.Code == 502)
- // {
- // Debug.Console(1, this, "Cannot reach App Server behind web server. Check that service/app is running on server");
- // }
- // else
- // {
- // Debug.Console(1, this, "Error response from server: {0}\n{1}", resp.Code, err);
- // }
- // }
- // else
- // {
- // Debug.Console(1, this, "No response. Server is likely unreachable");
- // }
- // StartReconnectTimer();
- // }
- // }
- // catch (Exception e)
- // {
- // Debug.Console(1, this, "Error Initializing Stream Client: {0}", e);
- // StartReconnectTimer();
- // RegisterLockEvent.Set();
- // }
- //}
-
///
/// Connects the Websocket Client
///
@@ -500,8 +407,16 @@ namespace PepperDash.Essentials
string message = JsonConvert.SerializeObject(o, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
Debug.Console(1, this, "Message TX: {0}", message);
var messageBytes = System.Text.Encoding.UTF8.GetBytes(message);
- WSClient.SendAsync(messageBytes, (uint)messageBytes.Length, WebSocketClient.WEBSOCKET_PACKET_TYPES.LWS_WS_OPCODE_07__TEXT_FRAME);
+ var result = WSClient.Send(messageBytes, (uint)messageBytes.Length, WebSocketClient.WEBSOCKET_PACKET_TYPES.LWS_WS_OPCODE_07__TEXT_FRAME);
+ if (result != WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_SUCCESS)
+ {
+ Debug.Console(1, this, "Socket send result error: {0}", result);
+ }
}
+ else if (!WSClient.Connected)
+ {
+ Debug.Console(1, this, "Cannot send. Not connected {0}");
+ }
}
///
@@ -703,7 +618,7 @@ namespace PepperDash.Essentials
{
if(result != WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_SUCCESS)
Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "SendCallback questionable result: {0}", result);
- return 0;
+ return 1;
}
///
@@ -716,7 +631,7 @@ namespace PepperDash.Essentials
if(string.IsNullOrEmpty(message))
return;
- Debug.Console(1, this, "Message RX: '{0}'", message);
+ Debug.Console(1, this, "Message RX: {0}", message);
try
{
var messageObj = JObject.Parse(message);
diff --git a/PepperDashEssentials/AppServer/Messengers/AtcDdvc01Messenger.cs b/PepperDashEssentials/AppServer/Messengers/AtcDdvc01Messenger.cs
new file mode 100644
index 00000000..c36702aa
--- /dev/null
+++ b/PepperDashEssentials/AppServer/Messengers/AtcDdvc01Messenger.cs
@@ -0,0 +1,127 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Crestron.SimplSharp;
+using Crestron.SimplSharpPro.DeviceSupport;
+using Crestron.SimplSharpPro.EthernetCommunication;
+
+using PepperDash.Core;
+using PepperDash.Essentials.Core;
+
+namespace PepperDash.Essentials.AppServer.Messengers
+{
+ public class Ddvc01AtcMessenger : MessengerBase
+ {
+ BasicTriList EISC;
+
+ const uint BKeypad1 = 201;
+ const uint BKeypad2 = 202;
+ const uint BKeypad3 = 203;
+ const uint BKeypad4 = 204;
+ const uint BKeypad5 = 205;
+ const uint BKeypad6 = 206;
+ const uint BKeypad7 = 207;
+ const uint BKeypad8 = 208;
+ const uint BKeypad9 = 209;
+ const uint BKeypad0 = 210;
+ const uint BKeypadStar = 211;
+ const uint BKeypadPound = 212;
+ const uint BDialHangup = 221;
+ const uint BIncomingAnswer = 251;
+ const uint BIncomingReject = 252;
+ const uint BSpeedDial1 = 241;
+ const uint BSpeedDial2 = 242;
+ const uint BSpeedDial3 = 243;
+ const uint BSpeedDial4 = 244;
+
+ const uint BIsOnHook = 222;
+ const uint BIsOffHook = 224;
+ const uint BDialHangupIsVisible = 251;
+ const uint BCallIsIncoming = 254;
+ const uint BSpeedDialIsVisible1 = 261;
+ const uint BSpeedDialIsVisible2 = 262;
+ const uint BSpeedDialIsVisible3 = 263;
+ const uint BSpeedDialIsVisible4 = 264;
+
+
+ const uint SCurrentDialString = 201;
+ const uint SSpeedDialName1 = 241;
+ const uint SSpeedDialName2 = 242;
+ const uint SSpeedDialName3 = 243;
+ const uint SSpeedDialName4 = 244;
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public Ddvc01AtcMessenger(BasicTriList eisc, string messagePath)
+ : base(messagePath)
+ {
+ EISC = eisc;
+
+ }
+
+ ///
+ ///
+ ///
+ void SendFullStatus()
+ {
+ this.PostStatusMessage(new
+ {
+ atc = new
+ {
+ callIsIncoming = EISC.GetBool(BCallIsIncoming),
+ isOnHook = EISC.GetBool(BIsOnHook),
+ isOffHook = EISC.GetBool(BIsOffHook),
+ dialHangupIsVisible = EISC.GetBool(BDialHangupIsVisible),
+ currentDialString = EISC.GetString(SCurrentDialString),
+ }
+ });
+ }
+
+ ///
+ ///
+ ///
+ ///
+ protected override void CustomRegisterWithAppServer(CotijaSystemController appServerController)
+ {
+ Action