From 320dfca2d55531f12589fa4ddf7a499f4171500a Mon Sep 17 00:00:00 2001 From: zznty <94796179+zznty@users.noreply.github.com> Date: Thu, 21 Jul 2022 22:06:25 +0700 Subject: [PATCH] add abstractions for controllers --- .../Abstractions/Controllers/IChatController.cs | 8 ++++++++ .../Abstractions/Controllers/IServerController.cs | 13 +++++++++++++ .../Abstractions/Controllers/ISettingsController.cs | 7 +++++++ .../Abstractions/Controllers/IWorldsController.cs | 10 ++++++++++ TorchRemote.Plugin/Controllers/ChatController.cs | 3 ++- TorchRemote.Plugin/Controllers/ServerController.cs | 3 ++- .../Controllers/SettingsController.cs | 3 ++- TorchRemote.Plugin/Controllers/WorldsController.cs | 3 ++- 8 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 TorchRemote.Plugin/Abstractions/Controllers/IChatController.cs create mode 100644 TorchRemote.Plugin/Abstractions/Controllers/IServerController.cs create mode 100644 TorchRemote.Plugin/Abstractions/Controllers/ISettingsController.cs create mode 100644 TorchRemote.Plugin/Abstractions/Controllers/IWorldsController.cs diff --git a/TorchRemote.Plugin/Abstractions/Controllers/IChatController.cs b/TorchRemote.Plugin/Abstractions/Controllers/IChatController.cs new file mode 100644 index 0000000..b7ca360 --- /dev/null +++ b/TorchRemote.Plugin/Abstractions/Controllers/IChatController.cs @@ -0,0 +1,8 @@ +using TorchRemote.Models.Requests; +namespace TorchRemote.Plugin.Abstractions.Controllers; + +public interface IChatController +{ + Task SendMessage(ChatMessageRequest request); + Task InvokeCommand(ChatCommandRequest request); +} diff --git a/TorchRemote.Plugin/Abstractions/Controllers/IServerController.cs b/TorchRemote.Plugin/Abstractions/Controllers/IServerController.cs new file mode 100644 index 0000000..55c388c --- /dev/null +++ b/TorchRemote.Plugin/Abstractions/Controllers/IServerController.cs @@ -0,0 +1,13 @@ +using TorchRemote.Models.Requests; +using TorchRemote.Models.Responses; +using TorchRemote.Models.Shared; +namespace TorchRemote.Plugin.Abstractions.Controllers; + +public interface IServerController +{ + ServerStatusResponse GetStatus(); + Task Start(); + Task Stop(StopServerRequest request); + ServerSettings GetSettings(); + Task SetSettings(ServerSettings request); +} diff --git a/TorchRemote.Plugin/Abstractions/Controllers/ISettingsController.cs b/TorchRemote.Plugin/Abstractions/Controllers/ISettingsController.cs new file mode 100644 index 0000000..bf54093 --- /dev/null +++ b/TorchRemote.Plugin/Abstractions/Controllers/ISettingsController.cs @@ -0,0 +1,7 @@ +using TorchRemote.Models.Responses; +namespace TorchRemote.Plugin.Abstractions.Controllers; + +public interface ISettingsController +{ + SettingInfoResponse Get(Guid id); +} diff --git a/TorchRemote.Plugin/Abstractions/Controllers/IWorldsController.cs b/TorchRemote.Plugin/Abstractions/Controllers/IWorldsController.cs new file mode 100644 index 0000000..4bd74d2 --- /dev/null +++ b/TorchRemote.Plugin/Abstractions/Controllers/IWorldsController.cs @@ -0,0 +1,10 @@ +using TorchRemote.Models.Responses; +namespace TorchRemote.Plugin.Abstractions.Controllers; + +public interface IWorldsController +{ + IEnumerable Get(); + Guid GetSelected(); + WorldResponse GetWorld(Guid id); + void Select(Guid id); +} diff --git a/TorchRemote.Plugin/Controllers/ChatController.cs b/TorchRemote.Plugin/Controllers/ChatController.cs index 84b90bd..76f46fb 100644 --- a/TorchRemote.Plugin/Controllers/ChatController.cs +++ b/TorchRemote.Plugin/Controllers/ChatController.cs @@ -17,12 +17,13 @@ using Torch.Utils; using TorchRemote.Models.Requests; using TorchRemote.Models.Responses; using TorchRemote.Models.Shared; +using TorchRemote.Plugin.Abstractions.Controllers; using TorchRemote.Plugin.Modules; using TorchRemote.Plugin.Utils; using VRage.Network; namespace TorchRemote.Plugin.Controllers; -public class ChatController : WebApiController +public class ChatController : WebApiController, IChatController { private const string RootPath = "/chat"; diff --git a/TorchRemote.Plugin/Controllers/ServerController.cs b/TorchRemote.Plugin/Controllers/ServerController.cs index a08afbf..d6e08cf 100644 --- a/TorchRemote.Plugin/Controllers/ServerController.cs +++ b/TorchRemote.Plugin/Controllers/ServerController.cs @@ -7,11 +7,12 @@ using Torch.API.Session; using TorchRemote.Models.Requests; using TorchRemote.Models.Responses; using TorchRemote.Models.Shared; +using TorchRemote.Plugin.Abstractions.Controllers; using TorchRemote.Plugin.Utils; namespace TorchRemote.Plugin.Controllers; -public class ServerController : WebApiController +public class ServerController : WebApiController, IServerController { private const string RootPath = "/server"; diff --git a/TorchRemote.Plugin/Controllers/SettingsController.cs b/TorchRemote.Plugin/Controllers/SettingsController.cs index 9884cb0..f20066c 100644 --- a/TorchRemote.Plugin/Controllers/SettingsController.cs +++ b/TorchRemote.Plugin/Controllers/SettingsController.cs @@ -3,10 +3,11 @@ using EmbedIO.Routing; using EmbedIO.WebApi; using Swan; using TorchRemote.Models.Responses; +using TorchRemote.Plugin.Abstractions.Controllers; using TorchRemote.Plugin.Utils; namespace TorchRemote.Plugin.Controllers; -public class SettingsController : WebApiController +public class SettingsController : WebApiController, ISettingsController { private const string RootPath = "/settings"; diff --git a/TorchRemote.Plugin/Controllers/WorldsController.cs b/TorchRemote.Plugin/Controllers/WorldsController.cs index 166a750..9be4386 100644 --- a/TorchRemote.Plugin/Controllers/WorldsController.cs +++ b/TorchRemote.Plugin/Controllers/WorldsController.cs @@ -3,10 +3,11 @@ using EmbedIO; using EmbedIO.Routing; using EmbedIO.WebApi; using TorchRemote.Models.Responses; +using TorchRemote.Plugin.Abstractions.Controllers; using TorchRemote.Plugin.Utils; namespace TorchRemote.Plugin.Controllers; -public class WorldsController : WebApiController +public class WorldsController : WebApiController, IWorldsController { private const string RootPath = "/worlds";