aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/FSE/Tango.FSE.UI/Console/DefaultConsoleService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/FSE/Tango.FSE.UI/Console/DefaultConsoleService.cs')
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.UI/Console/DefaultConsoleService.cs53
1 files changed, 53 insertions, 0 deletions
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Console/DefaultConsoleService.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/Console/DefaultConsoleService.cs
new file mode 100644
index 000000000..640b547a9
--- /dev/null
+++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Console/DefaultConsoleService.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.Console.Network;
+using Tango.Core;
+using Tango.Core.DI;
+using Tango.FSE.Common.Connection;
+using Tango.FSE.Common.Console;
+
+namespace Tango.FSE.UI.Console
+{
+ [TangoCreateWhenRegistered]
+ public class DefaultConsoleService : ExtendedObject, IConsoleService
+ {
+ public event EventHandler<GetCurrentDirectoryResponse> Initialized;
+
+ public string CurrentDirectory { get; private set; }
+
+ private IMachineProvider MachineProvider { get; set; }
+
+ public DefaultConsoleService(IMachineProvider machineProvider)
+ {
+ MachineProvider = machineProvider;
+ MachineProvider.MachineConnected += MachineProvider_MachineConnected;
+ }
+
+ private async void MachineProvider_MachineConnected(object sender, MachineConnectedEventArgs e)
+ {
+ try
+ {
+ var response = await MachineProvider.MachineOperator.SendGenericRequest<GetCurrentDirectoryRequest, GetCurrentDirectoryResponse>(new GetCurrentDirectoryRequest(), new Transport.TransportRequestConfig() { Timeout = TimeSpan.FromSeconds(10) });
+ Initialized?.Invoke(this, response);
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Error getting remote machine current console directory.");
+ }
+ }
+
+ public async Task<ConsoleCommandResponse> ExecuteCommand(ConsoleCommandRequest request, TimeSpan? timeout = null)
+ {
+ var response = await MachineProvider.MachineOperator.SendGenericRequest<ConsoleCommandRequest, ConsoleCommandResponse>(request, new Transport.TransportRequestConfig()
+ {
+ ShouldLog = true,
+ Timeout = timeout
+ });
+
+ return response;
+ }
+ }
+}