From ac393c4885bc4c0e0f0857d65bbb461db1e828ae Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 10 Mar 2026 17:35:23 -0600 Subject: [PATCH] refactor(force-patch): Remove obsolete GenericHttpClient class in favor of built-in HttpClient --- .../Comm and IR/GenericHttpClient.cs | 179 ------------------ 1 file changed, 179 deletions(-) delete mode 100644 src/PepperDash.Essentials.Core/Comm and IR/GenericHttpClient.cs diff --git a/src/PepperDash.Essentials.Core/Comm and IR/GenericHttpClient.cs b/src/PepperDash.Essentials.Core/Comm and IR/GenericHttpClient.cs deleted file mode 100644 index d1c3a7c8..00000000 --- a/src/PepperDash.Essentials.Core/Comm and IR/GenericHttpClient.cs +++ /dev/null @@ -1,179 +0,0 @@ -using Crestron.SimplSharp.Net.Http; -using PepperDash.Core; -using System; - -namespace PepperDash.Essentials.Core; - -[Obsolete("Please use the builtin HttpClient class instead: https://learn.microsoft.com/en-us/dotnet/fundamentals/networking/http/httpclient-guidelines")] - public class GenericHttpClient : Device, IBasicCommunication - { - private readonly HttpClient Client; - - /// - /// Event raised when response is received - /// - public event EventHandler ResponseRecived; - - /// - /// Constructor - /// - /// key of the device - /// name of the device - /// hostname for the HTTP client - public GenericHttpClient(string key, string name, string hostname) - : base(key, name) - { - Client = new HttpClient - { - HostName = hostname - }; - - - } - - /// - /// SendText method - /// - /// the path to send the request to - public void SendText(string path) - { - HttpClientRequest request = new HttpClientRequest(); - string url = string.Format("http://{0}/{1}", Client.HostName, path); - request.Url = new UrlParser(url); - HttpClient.DISPATCHASYNC_ERROR error = Client.DispatchAsyncEx(request, Response, request); - } - - /// - /// SendText method - /// - /// format for the items - /// items to format - public void SendText(string format, params object[] items) - { - HttpClientRequest request = new HttpClientRequest(); - string url = string.Format("http://{0}/{1}", Client.HostName, string.Format(format, items)); - request.Url = new UrlParser(url); - HttpClient.DISPATCHASYNC_ERROR error = Client.DispatchAsyncEx(request, Response, request); - } - - /// - /// SendTextNoResponse method - /// - /// format for the items - /// items to format - public void SendTextNoResponse(string format, params object[] items) - { - HttpClientRequest request = new HttpClientRequest(); - string url = string.Format("http://{0}/{1}", Client.HostName, string.Format(format, items)); - request.Url = new UrlParser(url); - Client.Dispatch(request); - } - - /// - /// Response method - /// - /// response received from the HTTP client - /// error status of the HTTP callback - /// original HTTP client request - private void Response(HttpClientResponse response, HTTP_CALLBACK_ERROR error, object request) - { - if (error == HTTP_CALLBACK_ERROR.COMPLETED) - { - var responseReceived = response; - - if (responseReceived.ContentString.Length > 0) - { - ResponseRecived?.Invoke(this, new GenericHttpClientEventArgs(responseReceived.ContentString, (request as HttpClientRequest).Url.ToString(), error)); - } - } - - } - - - #region IBasicCommunication Members - - /// - /// SendBytes method - /// - /// bytes to send - public void SendBytes(byte[] bytes) - { - throw new NotImplementedException(); - } - - - - #endregion - - #region ICommunicationReceiver Members - - /// - /// BytesReceived event - /// - public event EventHandler BytesReceived; - - /// - /// Connect method - /// - public void Connect() - { - throw new NotImplementedException(); - } - - /// - /// Disconnect method - /// - public void Disconnect() - { - throw new NotImplementedException(); - } - - /// - /// IsConnected property - /// - public bool IsConnected - { - get { return true; } - } - - /// - /// TextReceived event - /// - public event EventHandler TextReceived; - - #endregion - } - - /// - /// Represents a GenericHttpClientEventArgs - /// - public class GenericHttpClientEventArgs : EventArgs - { - /// - /// Gets or sets the ResponseText - /// - public string ResponseText { get; private set; } - - /// - /// Gets or sets the RequestPath - /// - public string RequestPath { get; private set; } - - /// - /// Gets or sets the Error - /// - public HTTP_CALLBACK_ERROR Error { get; set; } - - /// - /// Constructor - /// - /// response text - /// request path - /// error status - public GenericHttpClientEventArgs(string response, string request, HTTP_CALLBACK_ERROR error) - { - ResponseText = response; - RequestPath = request; - Error = error; - } - } \ No newline at end of file