diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-02-28 19:46:34 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-02-28 19:46:34 +0200 |
| commit | 18dafa9e98e171321d3847a208c0af5be6f57ef6 (patch) | |
| tree | 94d44edbe93ad2c95e62179ec8e2b1da9ce4dd13 /Software/Visual_Studio/PPC/Tango.PPC.Common/Console | |
| parent | 5f45be5bae69be7b7e916f02fb6d69b2db60e529 (diff) | |
| download | Tango-18dafa9e98e171321d3847a208c0af5be6f57ef6.tar.gz Tango-18dafa9e98e171321d3847a208c0af5be6f57ef6.zip | |
Implemented Transport Immediate mode on TCP and SignalR.
Implemented Tango.Console components.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/Console')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.Common/Console/DefaultConsoleEngineService.cs | 45 | ||||
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.Common/Console/IConsoleEngineService.cs | 13 |
2 files changed, 58 insertions, 0 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Console/DefaultConsoleEngineService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Console/DefaultConsoleEngineService.cs new file mode 100644 index 000000000..431545c33 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Console/DefaultConsoleEngineService.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Console; +using Tango.Core.DI; +using Tango.Integration.ExternalBridge; +using Tango.PPC.Common.ExternalBridge; +using Tango.Transport; + +namespace Tango.PPC.Common.Console +{ + [TangoCreateWhenRegistered] + public class DefaultConsoleEngineService : IConsoleEngineService, IExternalBridgeRequestHandler + { + public bool Enabled { get; set; } = true; + + public DefaultConsoleEngineService(IPPCExternalBridgeService externalBridge) + { + externalBridge.RegisterRequestHandler(this); + } + + [ExternalBridgeRequestHandlerMethod(typeof(ConsoleCommandDTO))] + public async void OnConsoleCommandReceived(ConsoleCommandDTO command, String token, ITransporter transporter) + { + if (Enabled) + { + try + { + ConsoleExecutionEngine engine = new ConsoleExecutionEngine(); + var result = await engine.Execute(command); + await transporter.SendGenericResponse<ConsoleCommandExecutionResult>(result, token, new TransportResponseConfig() + { + Immediate = true, + }); + } + catch (Exception ex) + { + await transporter.SendErrorResponse(ex, token); + } + } + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Console/IConsoleEngineService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Console/IConsoleEngineService.cs new file mode 100644 index 000000000..612ff302b --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Console/IConsoleEngineService.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Common.Console +{ + public interface IConsoleEngineService + { + bool Enabled { get; set; } + } +} |
