diff --git a/.gitignore b/.gitignore index 9b6ede8..9935935 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,5 @@ Thumbs.db obj/ [Rr]elease*/ _ReSharper*/ -SIMPLSharpLogs/ \ No newline at end of file +SIMPLSharpLogs/ +*.projectinfo \ No newline at end of file diff --git a/Pepperdash Core/.vs/Pepperdash Core/v14/.suo b/Pepperdash Core/.vs/Pepperdash Core/v14/.suo deleted file mode 100644 index 4b1acef..0000000 Binary files a/Pepperdash Core/.vs/Pepperdash Core/v14/.suo and /dev/null differ diff --git a/Pepperdash Core/CLZ Builds/PepperDash_Core.clz b/Pepperdash Core/CLZ Builds/PepperDash_Core.clz index 88e21c5..b6c27f1 100644 Binary files a/Pepperdash Core/CLZ Builds/PepperDash_Core.clz and b/Pepperdash Core/CLZ Builds/PepperDash_Core.clz differ diff --git a/Pepperdash Core/CLZ Builds/PepperDash_Core.dll b/Pepperdash Core/CLZ Builds/PepperDash_Core.dll index 7fe0247..8f72cb7 100644 Binary files a/Pepperdash Core/CLZ Builds/PepperDash_Core.dll and b/Pepperdash Core/CLZ Builds/PepperDash_Core.dll differ diff --git a/Pepperdash Core/Pepperdash Core.suo b/Pepperdash Core/Pepperdash Core.suo deleted file mode 100644 index d9b50e2..0000000 Binary files a/Pepperdash Core/Pepperdash Core.suo and /dev/null differ diff --git a/Pepperdash Core/Pepperdash Core/Comm/GenericHttpSseClient.cs b/Pepperdash Core/Pepperdash Core/Comm/GenericHttpSseClient.cs index bd0091f..9e5121f 100644 --- a/Pepperdash Core/Pepperdash Core/Comm/GenericHttpSseClient.cs +++ b/Pepperdash Core/Pepperdash Core/Comm/GenericHttpSseClient.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharp.CrestronIO; -using Crestron.SimplSharp.Net; using Crestron.SimplSharp.Net.Http; namespace PepperDash.Core @@ -36,8 +35,6 @@ namespace PepperDash.Core HttpClient Client; HttpClientRequest Request; - Connection SseConnection; - public GenericHttpSseClient(string key, string name) { @@ -78,38 +75,23 @@ namespace PepperDash.Core // In order to get a handle on the response stream, we have to get // the request stream first. Boo Client.BeginGetRequestStream(GetRequestStreamCallback, Request, null); - //CrestronConsole.PrintLine("Request made!"); + CrestronConsole.PrintLine("Request made!"); } catch (Exception e) { - ErrorLog.Notice("Exception occured in InitiateConnection(): " + e); + ErrorLog.Notice("Exception occured in AsyncWebPostHttps(): " + e.ToString()); } }); } public void CloseConnection(string s) { - try + if (Client != null) { - if (Client != null) - { - if (SseConnection != null) - { - // Gracefully dispose of any in use resources?? + Client.Abort(); + IsConnected = false; - SseConnection.Disconnect(); - SseConnection.Close(true); - - Client.Abort(); - } - IsConnected = false; - - Debug.Console(1, this, "Client Disconnected"); - } - } - catch (Exception e) - { - Debug.Console(1, this, "Error Closing SSE Connection: {0}", e); + Debug.Console(1, this, "Client Disconnected"); } } @@ -148,10 +130,14 @@ namespace PepperDash.Core // This closes up the GetResponseStream async var response = request.ThisClient.EndGetResponseStream(request); - SseConnection = response.DataConnection; + response.DataConnection.OnBytesReceived += new EventHandler(DataConnection_OnBytesReceived); + + IsConnected = true; Debug.Console(1, this, "Client Disconnected"); +#warning Need to explore using a heartbeat to verify connection to the server + Stream streamResponse = response.ContentStream; // Object containing various states to be passed back to async callback below RequestState asyncState = new RequestState(); @@ -177,6 +163,11 @@ namespace PepperDash.Core } } + void DataConnection_OnBytesReceived(object sender, EventArgs e) + { + Debug.Console(1, this, "DataConnection OnBytesReceived Fired"); + } + /// /// /// @@ -214,20 +205,13 @@ namespace PepperDash.Core return; } - try + Crestron.SimplSharp.CrestronIO.IAsyncResult asynchronousResult; + do { - Crestron.SimplSharp.CrestronIO.IAsyncResult asynchronousResult; - do - { - asynchronousResult = responseStream.BeginRead(requestState.BufferRead, 0, RequestState.BUFFER_SIZE, - new Crestron.SimplSharp.CrestronIO.AsyncCallback(ReadCallBack), requestState); - } - while (asynchronousResult.CompletedSynchronously && !requestState.Done); - } - catch (Exception e) - { - Debug.Console(1, this, "Exception: {0}", e); + asynchronousResult = responseStream.BeginRead(requestState.BufferRead, 0, RequestState.BUFFER_SIZE, + new Crestron.SimplSharp.CrestronIO.AsyncCallback(ReadCallBack), requestState); } + while (asynchronousResult.CompletedSynchronously && !requestState.Done); } else { diff --git a/Pepperdash Core/Pepperdash Core/PepperDash_Core.projectinfo b/Pepperdash Core/Pepperdash Core/PepperDash_Core.projectinfo deleted file mode 100644 index cbf9eae..0000000 Binary files a/Pepperdash Core/Pepperdash Core/PepperDash_Core.projectinfo and /dev/null differ