diff --git a/Essentials Core/PepperDashEssentialsBase/Display/MockDisplay.cs b/Essentials Core/PepperDashEssentialsBase/Display/MockDisplay.cs
index dfa09b78..50604e54 100644
--- a/Essentials Core/PepperDashEssentialsBase/Display/MockDisplay.cs
+++ b/Essentials Core/PepperDashEssentialsBase/Display/MockDisplay.cs
@@ -64,14 +64,14 @@ namespace PepperDash.Essentials.Core
if (!PowerIsOnFeedback.BoolValue && !_IsWarmingUp && !_IsCoolingDown)
{
_IsWarmingUp = true;
- IsWarmingUpFeedback.FireUpdate();
+ IsWarmingUpFeedback.InvokeFireUpdate();
// Fake power-up cycle
WarmupTimer = new CTimer(o =>
{
_IsWarmingUp = false;
_PowerIsOn = true;
- IsWarmingUpFeedback.FireUpdate();
- PowerIsOnFeedback.FireUpdate();
+ IsWarmingUpFeedback.InvokeFireUpdate();
+ PowerIsOnFeedback.InvokeFireUpdate();
}, WarmupTime);
}
}
@@ -84,14 +84,14 @@ namespace PepperDash.Essentials.Core
{
_IsCoolingDown = true;
_PowerIsOn = false;
- PowerIsOnFeedback.FireUpdate();
- IsCoolingDownFeedback.FireUpdate();
+ PowerIsOnFeedback.InvokeFireUpdate();
+ IsCoolingDownFeedback.InvokeFireUpdate();
// Fake cool-down cycle
CooldownTimer = new CTimer(o =>
{
Debug.Console(2, this, "Cooldown timer ending");
_IsCoolingDown = false;
- IsCoolingDownFeedback.FireUpdate();
+ IsCoolingDownFeedback.InvokeFireUpdate();
}, CooldownTime);
}
}
@@ -117,20 +117,20 @@ namespace PepperDash.Essentials.Core
public void SetVolume(ushort level)
{
- _FakeVolumeLevel = level;
- VolumeLevelFeedback.FireUpdate();
+ _FakeVolumeLevel = level;
+ VolumeLevelFeedback.InvokeFireUpdate();
}
public void MuteOn()
{
_IsMuted = true;
- MuteFeedback.FireUpdate();
+ MuteFeedback.InvokeFireUpdate();
}
public void MuteOff()
{
_IsMuted = false;
- MuteFeedback.FireUpdate();
+ MuteFeedback.InvokeFireUpdate();
}
public BoolFeedback MuteFeedback { get; private set; }
@@ -170,7 +170,7 @@ namespace PepperDash.Essentials.Core
public void MuteToggle()
{
_IsMuted = !_IsMuted;
- MuteFeedback.FireUpdate();
+ MuteFeedback.InvokeFireUpdate();
}
#endregion
diff --git a/Essentials Core/PepperDashEssentialsBase/Feedbacks/Feedbacks.cs b/Essentials Core/PepperDashEssentialsBase/Feedbacks/Feedbacks.cs
index 5883a320..b9fabcd1 100644
--- a/Essentials Core/PepperDashEssentialsBase/Feedbacks/Feedbacks.cs
+++ b/Essentials Core/PepperDashEssentialsBase/Feedbacks/Feedbacks.cs
@@ -28,8 +28,19 @@ namespace PepperDash.Essentials.Core
Cue = cue;
}
+ ///
+ /// Fires an update synchronously
+ ///
public abstract void FireUpdate();
+ ///
+ /// Fires the update asynchronously within a CrestronInvoke
+ ///
+ public void InvokeFireUpdate()
+ {
+ CrestronInvoke.BeginInvoke(o => FireUpdate());
+ }
+
protected void OnOutputChange()
{
if (OutputChange != null) OutputChange(this, EventArgs.Empty);
diff --git a/Essentials/PepperDashEssentials/Properties/AssemblyInfo.cs b/Essentials/PepperDashEssentials/Properties/AssemblyInfo.cs
index 88362ce9..622f1c19 100644
--- a/Essentials/PepperDashEssentials/Properties/AssemblyInfo.cs
+++ b/Essentials/PepperDashEssentials/Properties/AssemblyInfo.cs
@@ -4,5 +4,5 @@
[assembly: AssemblyCompany("PepperDash Technology Corp")]
[assembly: AssemblyProduct("PepperDashEssentials")]
[assembly: AssemblyCopyright("Copyright © PepperDash Technology Corp 2017")]
-[assembly: AssemblyVersion("1.0.11.*")]
+[assembly: AssemblyVersion("1.0.12.*")]
diff --git a/Essentials/PepperDashEssentials/Room/Cotija/CotijaSystemController.cs b/Essentials/PepperDashEssentials/Room/Cotija/CotijaSystemController.cs
index a3259fa4..0ffdf2bc 100644
--- a/Essentials/PepperDashEssentials/Room/Cotija/CotijaSystemController.cs
+++ b/Essentials/PepperDashEssentials/Room/Cotija/CotijaSystemController.cs
@@ -5,6 +5,7 @@ using System.Text;
using System.Text.RegularExpressions;
using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO;
+using Crestron.SimplSharpPro.CrestronThread;
using Crestron.SimplSharpPro;
using Crestron.SimplSharp.Net.Http;
using Newtonsoft.Json;
@@ -25,6 +26,8 @@ namespace PepperDash.Essentials
///
CEvent PostLockEvent = new CEvent(true, true);
+ Thread SseWorkerThread;
+
CotijaConfig Config;
HttpClient Client;
@@ -211,57 +214,63 @@ namespace PepperDash.Essentials
/// object to be serialized and sent in post body
public void PostToServer(EssentialsRoomBase room, JObject o)
{
- var ready = PostLockEvent.Wait(2000);
- if (!ready)
+ CrestronInvoke.BeginInvoke(oo =>
{
- Debug.Console(1, this, "PostToServer failed to enter after 2 seconds. Ignoring");
- return;
- }
-
- PostLockEvent.Reset();
- try
- {
- if (Client == null || NeedNewClient)
+ var ready = PostLockEvent.Wait(2000);
+ if (!ready)
{
- NeedNewClient = false;
- Client = new HttpClient();
+ Debug.Console(1, this, "PostToServer failed to enter after 2 seconds. Ignoring");
+ return;
}
- Client.Verbose = false;
- Client.KeepAlive = true;
- HttpClientRequest request = new HttpClientRequest();
- request.RequestType = RequestType.Post;
- string url = string.Format("http://{0}/api/system/{1}/status", Config.ServerUrl, SystemUuid);
- request.Url.Parse(url);
- request.KeepAlive = true;
- request.Header.ContentType = "application/json";
- // Ignore any null objects when serializing and remove formatting
- string ignored = JsonConvert.SerializeObject(o, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
- Debug.Console(1, this, "Posting to '{0}':\n{1}", url, ignored);
- request.ContentString = ignored;
- request.FinalizeHeader();
- Client.DispatchAsync(request, (r, err) => {
- Debug.Console(1, this, "POST result: {0}", err);
+ PostLockEvent.Reset();
+ try
+ {
+ if (Client == null || NeedNewClient)
+ {
+ NeedNewClient = false;
+ Client = new HttpClient();
+ }
+ Client.Verbose = false;
+ Client.KeepAlive = true;
- if (err == HTTP_CALLBACK_ERROR.COMPLETED)
+ HttpClientRequest request = new HttpClientRequest();
+ request.RequestType = RequestType.Post;
+ string url = string.Format("http://{0}/api/system/{1}/status", Config.ServerUrl, SystemUuid);
+ request.Url.Parse(url);
+ request.KeepAlive = true;
+ request.Header.ContentType = "application/json";
+ // Ignore any null objects when serializing and remove formatting
+ string ignored = JsonConvert.SerializeObject(o, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
+ Debug.Console(1, this, "Posting to '{0}':\n{1}", url, ignored);
+ request.ContentString = ignored;
+ request.FinalizeHeader();
+ Client.DispatchAsync(request, (r, err) =>
{
- Debug.Console(1, this, "Status Response Code: {0}", r.Code);
- PostLockEvent.Set();
- }
- else
- {
- // Try again. This client is hosed.
- NeedNewClient = true;
- PostLockEvent.Set();
- PostToServer(room, o);
- }
- });
- }
- catch(Exception e)
- {
- Debug.Console(1, this, "Error Posting to Server: {0}", e);
- PostLockEvent.Set();
- }
+ Debug.Console(1, this, "POST result: {0}", err);
+
+ if (err == HTTP_CALLBACK_ERROR.COMPLETED)
+ {
+ Debug.Console(1, this, "Status Response Code: {0}", r.Code);
+ PostLockEvent.Set();
+ }
+ else
+ {
+ // Try again. This client is hosed.
+ NeedNewClient = true;
+ PostLockEvent.Set();
+ PostToServer(room, o);
+ }
+ });
+ }
+ catch (Exception e)
+ {
+ Debug.Console(1, this, "Error Posting to Server: {0}", e);
+ PostLockEvent.Set();
+ }
+
+ });
+
}
///
@@ -406,13 +415,11 @@ namespace PepperDash.Essentials
///
void SSEClient_LineReceived(object sender, GenericCommMethodReceiveTextArgs e)
{
- //Debug.Console(1, this, "Received from Server: '{0}'", e.Text);
-
if(e.Text.IndexOf("data:") > -1)
{
var message = e.Text.Substring(6);
- Debug.Console(1, this, "Message: '{0}'", message);
+ Debug.Console(1, this, "Message RX: '{0}'", message);
try
{
diff --git a/Release Package/PepperDashEssentials.cpz b/Release Package/PepperDashEssentials.cpz
index fb23a39f..379e7395 100644
Binary files a/Release Package/PepperDashEssentials.cpz and b/Release Package/PepperDashEssentials.cpz differ
diff --git a/Release Package/PepperDashEssentials.dll b/Release Package/PepperDashEssentials.dll
index 29f8579a..ce598718 100644
Binary files a/Release Package/PepperDashEssentials.dll and b/Release Package/PepperDashEssentials.dll differ