Browse Source

Changed servers to use RPC Transport

Kenric Nugteren 2 years ago
parent
commit
33e8e6aa4e

+ 4 - 1
prs.server/Engines/GPS/GPSEngine.cs

@@ -12,6 +12,7 @@ using InABox.Clients;
 using InABox.Core;
 using InABox.Core;
 using InABox.DigitalMatter;
 using InABox.DigitalMatter;
 using InABox.IPC;
 using InABox.IPC;
+using InABox.Rpc;
 using PRSServer.Engines;
 using PRSServer.Engines;
 
 
 namespace PRSServer
 namespace PRSServer
@@ -226,7 +227,9 @@ namespace PRSServer
             CoreUtils.RegisterClasses();
             CoreUtils.RegisterClasses();
             ComalUtils.RegisterClasses();
             ComalUtils.RegisterClasses();
 
 
-            ClientFactory.SetClientType(typeof(IPCClient<>), Platform.GPSEngine, Version, DatabaseServerProperties.GetPipeName(Properties.Server));
+            var transport = new RpcClientPipeTransport(DatabaseServerProperties.GetPipeName(Properties.Server));
+            ClientFactory.SetClientType(typeof(RpcClient<>), Platform.GPSEngine, Version, transport);
+
             CheckConnection();
             CheckConnection();
 
 
             DMFactory.Initialise(Properties.DumpFormat, Properties.DumpFile);
             DMFactory.Initialise(Properties.DumpFormat, Properties.DumpFile);

+ 1 - 1
prs.server/Engines/PortStatus.cs

@@ -89,7 +89,7 @@ namespace PRSServer
         public string? FullDescription() => null;
         public string? FullDescription() => null;
     }
     }
     
     
-    public class PortStatusHandler : RpcCommandHandler<IEngine, PortStatusParameters, PortStatusResult> 
+    public class PortStatusHandler : RpcCommandHandler<IEngine, PortStatusCommand, PortStatusParameters, PortStatusResult> 
     {
     {
         protected override PortStatusResult Execute(IRpcSession session, PortStatusParameters? parameters) 
         protected override PortStatusResult Execute(IRpcSession session, PortStatusParameters? parameters) 
             => new() { Ports = Sender.PortStatusList() };
             => new() { Ports = Sender.PortStatusList() };

+ 5 - 1
prs.server/Engines/Scheduler/ScheduleEngine.cs

@@ -4,6 +4,7 @@ using Comal.TaskScheduler.Shared;
 using InABox.IPC;
 using InABox.IPC;
 using InABox.Clients;
 using InABox.Clients;
 using InABox.Core;
 using InABox.Core;
+using InABox.Rpc;
 
 
 namespace PRSServer
 namespace PRSServer
 {
 {
@@ -33,7 +34,10 @@ namespace PRSServer
                     Logger.Send(LogType.Error, "", "Server is blank!");
                     Logger.Send(LogType.Error, "", "Server is blank!");
                     return;
                     return;
                 }
                 }
-                ClientFactory.SetClientType(typeof(IPCClient<>), Platform.SchedulerEngine, Version, DatabaseServerProperties.GetPipeName(Properties.Server));
+
+                var transport = new RpcClientPipeTransport(DatabaseServerProperties.GetPipeName(Properties.Server));
+                ClientFactory.SetClientType(typeof(RpcClient<>), Platform.SchedulerEngine, Version, transport);
+
                 CheckConnection();
                 CheckConnection();
 
 
                 Logger.Send(LogType.Information, "", "Starting Scheduler: ");
                 Logger.Send(LogType.Information, "", "Starting Scheduler: ");

+ 3 - 1
prs.server/Engines/WebEngine/WebEngine.cs

@@ -7,6 +7,7 @@ using InABox.Clients;
 using InABox.Configuration;
 using InABox.Configuration;
 using InABox.Core;
 using InABox.Core;
 using InABox.Wpf.Reports;
 using InABox.Wpf.Reports;
+using InABox.Rpc;
 
 
 namespace PRSServer
 namespace PRSServer
 {
 {
@@ -29,7 +30,8 @@ namespace PRSServer
                 Logger.Send(LogType.Error, "", "Server is blank!");
                 Logger.Send(LogType.Error, "", "Server is blank!");
                 return;
                 return;
             }
             }
-            ClientFactory.SetClientType(typeof(IPCClient<>), Platform.WebEngine, Version, DatabaseServerProperties.GetPipeName(Properties.Server));
+            var transport = new RpcClientPipeTransport(DatabaseServerProperties.GetPipeName(Properties.Server));
+            ClientFactory.SetClientType(typeof(RpcClient<>), Platform.WebEngine, Version, transport);
 
 
             Logger.Send(LogType.Information, "", "Registering Classes");
             Logger.Send(LogType.Information, "", "Registering Classes");
 
 

+ 11 - 6
prs.server/Forms/ServerGrid.cs

@@ -22,6 +22,7 @@ using InABox.Database;
 using InABox.Database.SQLite;
 using InABox.Database.SQLite;
 using InABox.DynamicGrid;
 using InABox.DynamicGrid;
 using InABox.IPC;
 using InABox.IPC;
+using InABox.Rpc;
 using InABox.Wpf.Editors;
 using InABox.Wpf.Editors;
 using InABox.WPF;
 using InABox.WPF;
 using PRSClasses;
 using PRSClasses;
@@ -369,20 +370,22 @@ namespace PRSServer
                             {
                             {
                                 while (true)
                                 while (true)
                                 {
                                 {
-                                    var client = IPCClientFactory.GetClient(DatabaseServerProperties.GetPipeName(key));
+                                    var transport = new RpcClientPipeTransport(DatabaseServerProperties.GetPipeName(key));
 
 
-                                    var response = client.Send(IPCMessage.Info(new InfoRequest()), 10_000).GetResponse<InfoResponse>();
-                                    if (response.Status != StatusCode.Error)
+                                    try
                                     {
                                     {
-                                        SecureConnections[key] = response.Info.IsHTTPS;
+                                        var response = transport.Send<RpcInfoCommand, RpcInfoParameters, RpcInfoResult>(new RpcInfoParameters());
+                                        SecureConnections[key] = response.Info?.IsHTTPS ?? false;
                                         break;
                                         break;
                                     }
                                     }
-                                    else
+                                    catch
                                     {
                                     {
                                         SecureConnections.Remove(key);
                                         SecureConnections.Remove(key);
                                         var service = GetService(key);
                                         var service = GetService(key);
                                         if (service is null || service.Status != ServiceControllerStatus.Running)
                                         if (service is null || service.Status != ServiceControllerStatus.Running)
+                                        {
                                             break;
                                             break;
+                                        }
                                     }
                                     }
                                 }
                                 }
                                 Dispatcher.Invoke(() =>
                                 Dispatcher.Invoke(() =>
@@ -1087,7 +1090,9 @@ namespace PRSServer
                         currentServerPort = null;
                         currentServerPort = null;
                         currentServerURL = null;
                         currentServerURL = null;
                         currentServerName = pipeName;
                         currentServerName = pipeName;
-                        ClientFactory.SetClientType(typeof(IPCClient<>), Platform.Server, CoreUtils.GetVersion(), pipeName);
+
+                        var transport = new RpcClientPipeTransport(pipeName);
+                        ClientFactory.SetClientType(typeof(RpcClient<>), Platform.Server, CoreUtils.GetVersion(), transport);
                         using (new WaitCursor())
                         using (new WaitCursor())
                         {
                         {
                             if (!Client.Ping())
                             if (!Client.Ping())