diff --git a/Essentials/PepperDashEssentials/Room/Cotija/CotijaSystemController.cs b/Essentials/PepperDashEssentials/Room/Cotija/CotijaSystemController.cs index 018e1441..385b09ca 100644 --- a/Essentials/PepperDashEssentials/Room/Cotija/CotijaSystemController.cs +++ b/Essentials/PepperDashEssentials/Room/Cotija/CotijaSystemController.cs @@ -20,6 +20,11 @@ namespace PepperDash.Essentials CCriticalSection FileLock; + /// + /// Prevents post operations from stomping on each other and getting lost + /// + CMutex PostLock = new CMutex(); + CotijaConfig Config; HttpClient Client; @@ -42,6 +47,8 @@ namespace PepperDash.Essentials long ButtonHeartbeatInterval = 1000; + bool NeedNewClient; + public CotijaSystemController(string key, string name, CotijaConfig config) : base(key, name) { Config = config; @@ -151,8 +158,9 @@ namespace PepperDash.Essentials } FileLock = new CCriticalSection(); +#warning NEIL I think we need to review this usage. Don't think it ever blocks - if (FileLock.TryEnter()) + if (FileLock.TryEnter()) { Debug.Console(1, this, "Reading configuration file to extract system UUID..."); @@ -203,11 +211,20 @@ namespace PepperDash.Essentials /// object to be serialized and sent in post body public void PostToServer(EssentialsRoomBase room, JObject o) { + var go = PostLock.WaitForMutex(2000); + if (!go) + { + Debug.Console(0, this, "Mutex not released after 2 seconds. Skipping message"); + return; + } try { - if(Client == null) - Client = new HttpClient(); - Client.Verbose = true; + if (Client == null || NeedNewClient) + { + NeedNewClient = false; + Client = new HttpClient(); + } + Client.Verbose = false; Client.KeepAlive = true; HttpClientRequest request = new HttpClientRequest(); @@ -221,13 +238,24 @@ namespace PepperDash.Essentials Debug.Console(1, this, "Posting to '{0}':\n{1}", url, ignored); request.ContentString = ignored; request.FinalizeHeader(); - Client.DispatchAsync(request, (r, err) => { if (r != null) { Debug.Console(1, this, "Status Response Code: {0}", r.Code); } }); + Client.DispatchAsync(request, (r, err) => { + Debug.Console(1, this, "POST result: {0}", err); - //ResetOrStartHearbeatTimer(); + if (err == HTTP_CALLBACK_ERROR.COMPLETED) + Debug.Console(1, this, "Status Response Code: {0}", r.Code); + else + { + // Try again. This client is hosed. + NeedNewClient = true; + PostToServer(room, o); + } + PostLock.ReleaseMutex(); + }); } catch(Exception e) { Debug.Console(1, this, "Error Posting to Server: {0}", e); + PostLock.ReleaseMutex(); } } diff --git a/Essentials/PepperDashEssentials/UIDrivers/VC/EssentialsVideoCodecUiDriver.cs b/Essentials/PepperDashEssentials/UIDrivers/VC/EssentialsVideoCodecUiDriver.cs index 258af091..d5fc382d 100644 --- a/Essentials/PepperDashEssentials/UIDrivers/VC/EssentialsVideoCodecUiDriver.cs +++ b/Essentials/PepperDashEssentials/UIDrivers/VC/EssentialsVideoCodecUiDriver.cs @@ -79,6 +79,7 @@ namespace PepperDash.Essentials.UIDrivers.VC StringBuilder SearchStringBuilder = new StringBuilder(); BoolFeedback SearchStringBackspaceVisibleFeedback; +#warning WHAT THE HELL happened to this????? BoolFeedback LayoutButtonEnableFeedback; ModalDialog IncomingCallModal; diff --git a/Release Package/PepperDashEssentials.cpz b/Release Package/PepperDashEssentials.cpz index 49906534..887f8efa 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 841b061c..02f9ae37 100644 Binary files a/Release Package/PepperDashEssentials.dll and b/Release Package/PepperDashEssentials.dll differ