mirror of
https://github.com/PepperDash/PepperDashCore.git
synced 2026-01-11 19:44:44 +00:00
refactor: Changed CWS references to WebApi, re-organized Web folder
This commit is contained in:
@@ -93,9 +93,9 @@
|
||||
<Compile Include="Comm\TcpServerConfigObject.cs" />
|
||||
<Compile Include="Config\PortalConfigReader.cs" />
|
||||
<Compile Include="CoreInterfaces.cs" />
|
||||
<Compile Include="CrestronWebServer\CwsBaseHandler.cs" />
|
||||
<Compile Include="CrestronWebServer\GenericCwsBase.cs" />
|
||||
<Compile Include="CrestronWebServer\CwsDefaultRequestHandler.cs" />
|
||||
<Compile Include="Web\RequestHandlers\WebApiBaseRequestHandler.cs" />
|
||||
<Compile Include="Web\WebApiServer.cs" />
|
||||
<Compile Include="Web\RequestHandlers\DefaultRequestRequestHandler.cs" />
|
||||
<Compile Include="EventArgs.cs" />
|
||||
<Compile Include="GenericRESTfulCommunications\Constants.cs" />
|
||||
<Compile Include="GenericRESTfulCommunications\GenericRESTfulClient.cs" />
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=CrestronWebServer/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=CrestronWebServer/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=Web/@EntryIndexedValue">False</s:Boolean></wpf:ResourceDictionary>
|
||||
@@ -1,8 +1,8 @@
|
||||
using Crestron.SimplSharp.WebScripting;
|
||||
|
||||
namespace PepperDash.Core
|
||||
namespace PepperDash.Core.Web.RequestHandlers
|
||||
{
|
||||
public class CwsDefaultRequestHandler : CwsBaseHandler
|
||||
public class DefaultRequestRequestHandler : WebApiBaseRequestHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles CONNECT method requests
|
||||
@@ -1,21 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Crestron.SimplSharp.WebScripting;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace PepperDash.Core
|
||||
namespace PepperDash.Core.Web.RequestHandlers
|
||||
{
|
||||
/// <summary>
|
||||
/// CWS Base Handler, implements IHttpCwsHandler
|
||||
/// </summary>
|
||||
public abstract class CwsBaseHandler : IHttpCwsHandler
|
||||
public abstract class WebApiBaseRequestHandler : IHttpCwsHandler
|
||||
{
|
||||
private readonly Dictionary<string, Action<HttpCwsContext>> _handlers;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
protected CwsBaseHandler()
|
||||
protected WebApiBaseRequestHandler()
|
||||
{
|
||||
_handlers = new Dictionary<string, Action<HttpCwsContext>>
|
||||
{
|
||||
@@ -1,12 +1,14 @@
|
||||
using System;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharp.WebScripting;
|
||||
using PepperDash.Core.Web.RequestHandlers;
|
||||
|
||||
namespace PepperDash.Core
|
||||
namespace PepperDash.Core.Web
|
||||
{
|
||||
public class GenericCwsBase : Device
|
||||
public class WebApiServer : IKeyName
|
||||
{
|
||||
private const string SplusKey = "Uninitialized CWS Server";
|
||||
private const string SplusKey = "Uninitialized Web API Server";
|
||||
private const string DefaultName = "Web API Server";
|
||||
private const string DefaultBasePath = "/api";
|
||||
|
||||
private const uint DebugTrace = 0;
|
||||
@@ -16,6 +18,9 @@ namespace PepperDash.Core
|
||||
private HttpCwsServer _server;
|
||||
private readonly CCriticalSection _serverLock = new CCriticalSection();
|
||||
|
||||
public string Key { get; private set; }
|
||||
public string Name { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// CWS base path, will default to "/api" if not set via initialize method
|
||||
/// </summary>
|
||||
@@ -29,11 +34,9 @@ namespace PepperDash.Core
|
||||
/// <summary>
|
||||
/// Constructor for S+. Make sure to set necessary properties using init method
|
||||
/// </summary>
|
||||
public GenericCwsBase()
|
||||
: base(SplusKey)
|
||||
public WebApiServer()
|
||||
: this(SplusKey, DefaultName, null)
|
||||
{
|
||||
CrestronEnvironment.ProgramStatusEventHandler += CrestronEnvironment_ProgramStatusEventHandler;
|
||||
CrestronEnvironment.EthernetEventHandler += CrestronEnvironment_EthernetEventHandler;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -41,10 +44,9 @@ namespace PepperDash.Core
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="basePath"></param>
|
||||
public GenericCwsBase(string key, string basePath)
|
||||
: base(key)
|
||||
public WebApiServer(string key, string basePath)
|
||||
: this(key, DefaultName, basePath)
|
||||
{
|
||||
BasePath = string.IsNullOrEmpty(basePath) ? DefaultBasePath : basePath;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -53,10 +55,14 @@ namespace PepperDash.Core
|
||||
/// <param name="key"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="basePath"></param>
|
||||
public GenericCwsBase(string key, string name, string basePath)
|
||||
: base(key, name)
|
||||
public WebApiServer(string key, string name, string basePath)
|
||||
{
|
||||
Key = key;
|
||||
Name = string.IsNullOrEmpty(name) ? DefaultName : name;
|
||||
BasePath = string.IsNullOrEmpty(basePath) ? DefaultBasePath : basePath;
|
||||
|
||||
CrestronEnvironment.ProgramStatusEventHandler += CrestronEnvironment_ProgramStatusEventHandler;
|
||||
CrestronEnvironment.EthernetEventHandler += CrestronEnvironment_EthernetEventHandler;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -148,7 +154,7 @@ namespace PepperDash.Core
|
||||
|
||||
_server = new HttpCwsServer(BasePath)
|
||||
{
|
||||
HttpRequestHandler = new CwsDefaultRequestHandler()
|
||||
HttpRequestHandler = new DefaultRequestRequestHandler()
|
||||
};
|
||||
|
||||
IsRegistered = _server.Register();
|
||||
Reference in New Issue
Block a user