diff --git a/Agent/Phantom.Agent.Rpc/ControllerConnection.cs b/Agent/Phantom.Agent.Rpc/ControllerConnection.cs index 01f87f7..61f232c 100644 --- a/Agent/Phantom.Agent.Rpc/ControllerConnection.cs +++ b/Agent/Phantom.Agent.Rpc/ControllerConnection.cs @@ -1,6 +1,6 @@ using Phantom.Common.Messages.Agent; using Phantom.Utils.Logging; -using Phantom.Utils.Rpc; +using Phantom.Utils.Rpc.Runtime; using Serilog; namespace Phantom.Agent.Rpc; diff --git a/Agent/Phantom.Agent.Rpc/KeepAliveLoop.cs b/Agent/Phantom.Agent.Rpc/KeepAliveLoop.cs index 25b4f53..462a5d8 100644 --- a/Agent/Phantom.Agent.Rpc/KeepAliveLoop.cs +++ b/Agent/Phantom.Agent.Rpc/KeepAliveLoop.cs @@ -1,7 +1,7 @@ using Phantom.Common.Messages.Agent; using Phantom.Common.Messages.Agent.ToController; using Phantom.Utils.Logging; -using Phantom.Utils.Rpc; +using Phantom.Utils.Rpc.Runtime; using Serilog; namespace Phantom.Agent.Rpc; diff --git a/Agent/Phantom.Agent.Rpc/RpcClientRuntime.cs b/Agent/Phantom.Agent.Rpc/RpcClientRuntime.cs index f558f3a..f56d48f 100644 --- a/Agent/Phantom.Agent.Rpc/RpcClientRuntime.cs +++ b/Agent/Phantom.Agent.Rpc/RpcClientRuntime.cs @@ -4,7 +4,7 @@ using Phantom.Common.Data.Agent; using Phantom.Common.Messages.Agent; using Phantom.Common.Messages.Agent.BiDirectional; using Phantom.Common.Messages.Agent.ToController; -using Phantom.Utils.Rpc; +using Phantom.Utils.Rpc.Runtime; using Phantom.Utils.Rpc.Sockets; using Phantom.Utils.Tasks; using Serilog; diff --git a/Agent/Phantom.Agent.Services/Rpc/MessageListener.cs b/Agent/Phantom.Agent.Services/Rpc/MessageListener.cs index cabf927..053c20c 100644 --- a/Agent/Phantom.Agent.Services/Rpc/MessageListener.cs +++ b/Agent/Phantom.Agent.Services/Rpc/MessageListener.cs @@ -5,8 +5,8 @@ using Phantom.Common.Messages.Agent.BiDirectional; using Phantom.Common.Messages.Agent.ToAgent; using Phantom.Common.Messages.Agent.ToController; using Phantom.Utils.Logging; -using Phantom.Utils.Rpc; using Phantom.Utils.Rpc.Message; +using Phantom.Utils.Rpc.Runtime; using Serilog; namespace Phantom.Agent.Services.Rpc; diff --git a/Controller/Phantom.Controller.Rpc/Phantom.Controller.Rpc.csproj b/Controller/Phantom.Controller.Rpc/Phantom.Controller.Rpc.csproj deleted file mode 100644 index 6b83469..0000000 --- a/Controller/Phantom.Controller.Rpc/Phantom.Controller.Rpc.csproj +++ /dev/null @@ -1,13 +0,0 @@ -<Project Sdk="Microsoft.NET.Sdk"> - - <PropertyGroup> - <ImplicitUsings>enable</ImplicitUsings> - <Nullable>enable</Nullable> - </PropertyGroup> - - <ItemGroup> - <ProjectReference Include="..\..\Common\Phantom.Common.Messages.Agent\Phantom.Common.Messages.Agent.csproj" /> - <ProjectReference Include="..\..\Common\Phantom.Common.Messages.Web\Phantom.Common.Messages.Web.csproj" /> - </ItemGroup> - -</Project> diff --git a/Controller/Phantom.Controller.Services/Agents/AgentConnection.cs b/Controller/Phantom.Controller.Services/Agents/AgentConnection.cs index 5e5f460..c198313 100644 --- a/Controller/Phantom.Controller.Services/Agents/AgentConnection.cs +++ b/Controller/Phantom.Controller.Services/Agents/AgentConnection.cs @@ -1,5 +1,5 @@ using Phantom.Common.Messages.Agent; -using Phantom.Controller.Rpc; +using Phantom.Utils.Rpc.Runtime; namespace Phantom.Controller.Services.Agents; diff --git a/Controller/Phantom.Controller.Services/Agents/AgentManager.cs b/Controller/Phantom.Controller.Services/Agents/AgentManager.cs index a540bbd..7adb181 100644 --- a/Controller/Phantom.Controller.Services/Agents/AgentManager.cs +++ b/Controller/Phantom.Controller.Services/Agents/AgentManager.cs @@ -5,11 +5,11 @@ using Phantom.Common.Data.Replies; using Phantom.Common.Messages.Agent; using Phantom.Common.Messages.Agent.ToAgent; using Phantom.Controller.Database; -using Phantom.Controller.Rpc; using Phantom.Controller.Services.Instances; using Phantom.Utils.Collections; using Phantom.Utils.Events; using Phantom.Utils.Logging; +using Phantom.Utils.Rpc.Runtime; using Phantom.Utils.Tasks; using Serilog; diff --git a/Controller/Phantom.Controller.Services/ControllerServices.cs b/Controller/Phantom.Controller.Services/ControllerServices.cs index a6e9f6d..d56c2a1 100644 --- a/Controller/Phantom.Controller.Services/ControllerServices.cs +++ b/Controller/Phantom.Controller.Services/ControllerServices.cs @@ -3,13 +3,13 @@ using Phantom.Common.Messages.Agent; using Phantom.Common.Messages.Web; using Phantom.Controller.Database; using Phantom.Controller.Minecraft; -using Phantom.Controller.Rpc; using Phantom.Controller.Services.Agents; using Phantom.Controller.Services.Events; using Phantom.Controller.Services.Instances; using Phantom.Controller.Services.Rpc; using Phantom.Controller.Services.Users; using Phantom.Utils.Logging; +using Phantom.Utils.Rpc.Runtime; using Phantom.Utils.Tasks; namespace Phantom.Controller.Services; diff --git a/Controller/Phantom.Controller.Services/Phantom.Controller.Services.csproj b/Controller/Phantom.Controller.Services/Phantom.Controller.Services.csproj index d400e20..37e7866 100644 --- a/Controller/Phantom.Controller.Services/Phantom.Controller.Services.csproj +++ b/Controller/Phantom.Controller.Services/Phantom.Controller.Services.csproj @@ -10,12 +10,13 @@ </ItemGroup> <ItemGroup> - <ProjectReference Include="..\..\Common\Phantom.Common.Data\Phantom.Common.Data.csproj" /> <ProjectReference Include="..\..\Common\Phantom.Common.Data.Web\Phantom.Common.Data.Web.csproj" /> + <ProjectReference Include="..\..\Common\Phantom.Common.Data\Phantom.Common.Data.csproj" /> + <ProjectReference Include="..\..\Common\Phantom.Common.Messages.Agent\Phantom.Common.Messages.Agent.csproj" /> + <ProjectReference Include="..\..\Common\Phantom.Common.Messages.Web\Phantom.Common.Messages.Web.csproj" /> <ProjectReference Include="..\..\Utils\Phantom.Utils.Events\Phantom.Utils.Events.csproj" /> <ProjectReference Include="..\Phantom.Controller.Database\Phantom.Controller.Database.csproj" /> <ProjectReference Include="..\Phantom.Controller.Minecraft\Phantom.Controller.Minecraft.csproj" /> - <ProjectReference Include="..\Phantom.Controller.Rpc\Phantom.Controller.Rpc.csproj" /> </ItemGroup> </Project> diff --git a/Controller/Phantom.Controller.Services/Rpc/AgentMessageListener.cs b/Controller/Phantom.Controller.Services/Rpc/AgentMessageListener.cs index 9f17a07..23d639e 100644 --- a/Controller/Phantom.Controller.Services/Rpc/AgentMessageListener.cs +++ b/Controller/Phantom.Controller.Services/Rpc/AgentMessageListener.cs @@ -4,11 +4,11 @@ using Phantom.Common.Messages.Agent; using Phantom.Common.Messages.Agent.BiDirectional; using Phantom.Common.Messages.Agent.ToAgent; using Phantom.Common.Messages.Agent.ToController; -using Phantom.Controller.Rpc; using Phantom.Controller.Services.Agents; using Phantom.Controller.Services.Events; using Phantom.Controller.Services.Instances; using Phantom.Utils.Rpc.Message; +using Phantom.Utils.Rpc.Runtime; using Phantom.Utils.Tasks; namespace Phantom.Controller.Services.Rpc; diff --git a/Controller/Phantom.Controller.Services/Rpc/WebMessageListener.cs b/Controller/Phantom.Controller.Services/Rpc/WebMessageListener.cs index 0317fda..c7d13d5 100644 --- a/Controller/Phantom.Controller.Services/Rpc/WebMessageListener.cs +++ b/Controller/Phantom.Controller.Services/Rpc/WebMessageListener.cs @@ -13,13 +13,13 @@ using Phantom.Common.Messages.Web.BiDirectional; using Phantom.Common.Messages.Web.ToController; using Phantom.Common.Messages.Web.ToWeb; using Phantom.Controller.Minecraft; -using Phantom.Controller.Rpc; using Phantom.Controller.Services.Agents; using Phantom.Controller.Services.Events; using Phantom.Controller.Services.Instances; using Phantom.Controller.Services.Users; using Phantom.Utils.Logging; using Phantom.Utils.Rpc.Message; +using Phantom.Utils.Rpc.Runtime; using Phantom.Utils.Tasks; using Serilog; diff --git a/Controller/Phantom.Controller/Phantom.Controller.csproj b/Controller/Phantom.Controller/Phantom.Controller.csproj index 1bd64ea..89d24dc 100644 --- a/Controller/Phantom.Controller/Phantom.Controller.csproj +++ b/Controller/Phantom.Controller/Phantom.Controller.csproj @@ -15,7 +15,6 @@ <ProjectReference Include="..\..\Utils\Phantom.Utils\Phantom.Utils.csproj" /> <ProjectReference Include="..\Phantom.Controller.Database.Postgres\Phantom.Controller.Database.Postgres.csproj" /> <ProjectReference Include="..\Phantom.Controller.Minecraft\Phantom.Controller.Minecraft.csproj" /> - <ProjectReference Include="..\Phantom.Controller.Rpc\Phantom.Controller.Rpc.csproj" /> <ProjectReference Include="..\Phantom.Controller.Services\Phantom.Controller.Services.csproj" /> </ItemGroup> diff --git a/Controller/Phantom.Controller/Program.cs b/Controller/Phantom.Controller/Program.cs index ddd979d..850ae98 100644 --- a/Controller/Phantom.Controller/Program.cs +++ b/Controller/Phantom.Controller/Program.cs @@ -4,11 +4,11 @@ using Phantom.Common.Messages.Agent; using Phantom.Common.Messages.Web; using Phantom.Controller; using Phantom.Controller.Database.Postgres; -using Phantom.Controller.Rpc; using Phantom.Controller.Services; using Phantom.Utils.IO; using Phantom.Utils.Logging; using Phantom.Utils.Rpc; +using Phantom.Utils.Rpc.Runtime; using Phantom.Utils.Runtime; using Phantom.Utils.Tasks; @@ -64,8 +64,8 @@ try { try { await Task.WhenAll( - RpcRuntime.Launch(ConfigureRpc("Agent", agentRpcServerHost, agentRpcServerPort, agentKeyData), AgentMessageRegistries.Definitions, controllerServices.CreateAgentMessageListener, shutdownCancellationToken), - RpcRuntime.Launch(ConfigureRpc("Web", webRpcServerHost, webRpcServerPort, webKeyData), WebMessageRegistries.Definitions, controllerServices.CreateWebMessageListener, shutdownCancellationToken) + RpcServerRuntime.Launch(ConfigureRpc("Agent", agentRpcServerHost, agentRpcServerPort, agentKeyData), AgentMessageRegistries.Definitions, controllerServices.CreateAgentMessageListener, shutdownCancellationToken), + RpcServerRuntime.Launch(ConfigureRpc("Web", webRpcServerHost, webRpcServerPort, webKeyData), WebMessageRegistries.Definitions, controllerServices.CreateWebMessageListener, shutdownCancellationToken) ); } finally { NetMQConfig.Cleanup(); diff --git a/PhantomPanel.sln b/PhantomPanel.sln index b913bd0..75b1dfa 100644 --- a/PhantomPanel.sln +++ b/PhantomPanel.sln @@ -40,8 +40,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Phantom.Controller.Database EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Phantom.Controller.Minecraft", "Controller\Phantom.Controller.Minecraft\Phantom.Controller.Minecraft.csproj", "{4B3B73E6-48DD-4846-87FD-DFB86619B67C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Phantom.Controller.Rpc", "Controller\Phantom.Controller.Rpc\Phantom.Controller.Rpc.csproj", "{79312D72-44E0-431D-96A4-4C0A066B9671}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Phantom.Controller.Services", "Controller\Phantom.Controller.Services\Phantom.Controller.Services.csproj", "{90F0F1B1-EB0A-49C9-8DF0-1153A87F77C9}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Phantom.Utils", "Utils\Phantom.Utils\Phantom.Utils.csproj", "{384885E2-5113-45C5-9B15-09BDA0911852}" @@ -120,10 +118,6 @@ Global {4B3B73E6-48DD-4846-87FD-DFB86619B67C}.Debug|Any CPU.Build.0 = Debug|Any CPU {4B3B73E6-48DD-4846-87FD-DFB86619B67C}.Release|Any CPU.ActiveCfg = Release|Any CPU {4B3B73E6-48DD-4846-87FD-DFB86619B67C}.Release|Any CPU.Build.0 = Release|Any CPU - {79312D72-44E0-431D-96A4-4C0A066B9671}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {79312D72-44E0-431D-96A4-4C0A066B9671}.Debug|Any CPU.Build.0 = Debug|Any CPU - {79312D72-44E0-431D-96A4-4C0A066B9671}.Release|Any CPU.ActiveCfg = Release|Any CPU - {79312D72-44E0-431D-96A4-4C0A066B9671}.Release|Any CPU.Build.0 = Release|Any CPU {90F0F1B1-EB0A-49C9-8DF0-1153A87F77C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {90F0F1B1-EB0A-49C9-8DF0-1153A87F77C9}.Debug|Any CPU.Build.0 = Debug|Any CPU {90F0F1B1-EB0A-49C9-8DF0-1153A87F77C9}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -175,7 +169,6 @@ Global {E3AD566F-384A-489A-A3BB-EA3BA400C18C} = {0AB9471E-6228-4EB7-802E-3102B3952AAD} {81625B4A-3DB6-48BD-A739-D23DA02107D1} = {0AB9471E-6228-4EB7-802E-3102B3952AAD} {4B3B73E6-48DD-4846-87FD-DFB86619B67C} = {0AB9471E-6228-4EB7-802E-3102B3952AAD} - {79312D72-44E0-431D-96A4-4C0A066B9671} = {0AB9471E-6228-4EB7-802E-3102B3952AAD} {90F0F1B1-EB0A-49C9-8DF0-1153A87F77C9} = {0AB9471E-6228-4EB7-802E-3102B3952AAD} {384885E2-5113-45C5-9B15-09BDA0911852} = {AA217EB8-E480-456B-BDF3-39419EF2AD85} {2E81523B-5DBE-4992-A77B-1679758D0688} = {AA217EB8-E480-456B-BDF3-39419EF2AD85} diff --git a/Utils/Phantom.Utils.Rpc/Message/MessageHandler.cs b/Utils/Phantom.Utils.Rpc/Message/MessageHandler.cs index cc770e3..92e8df7 100644 --- a/Utils/Phantom.Utils.Rpc/Message/MessageHandler.cs +++ b/Utils/Phantom.Utils.Rpc/Message/MessageHandler.cs @@ -3,7 +3,7 @@ using Serilog; namespace Phantom.Utils.Rpc.Message; -public abstract class MessageHandler<TListener> { +abstract class MessageHandler<TListener> { private readonly TListener listener; private readonly ILogger logger; private readonly TaskManager taskManager; diff --git a/Utils/Phantom.Utils.Rpc/Message/MessageRegistry.cs b/Utils/Phantom.Utils.Rpc/Message/MessageRegistry.cs index 2122621..d6d0f63 100644 --- a/Utils/Phantom.Utils.Rpc/Message/MessageRegistry.cs +++ b/Utils/Phantom.Utils.Rpc/Message/MessageRegistry.cs @@ -36,7 +36,7 @@ public sealed class MessageRegistry<TListener> { codeToTypeMapping.Add(code, typeof(TMessage)); } - public bool TryGetType(ReadOnlyMemory<byte> data, [NotNullWhen(true)] out Type? type) { + internal bool TryGetType(ReadOnlyMemory<byte> data, [NotNullWhen(true)] out Type? type) { try { var code = MessageSerializer.ReadCode(ref data); return codeToTypeMapping.TryGetValue(code, out type); @@ -78,7 +78,7 @@ public sealed class MessageRegistry<TListener> { } } - public void Handle(ReadOnlyMemory<byte> data, MessageHandler<TListener> handler) { + internal void Handle(ReadOnlyMemory<byte> data, MessageHandler<TListener> handler) { ushort code; try { code = MessageSerializer.ReadCode(ref data); diff --git a/Utils/Phantom.Utils.Rpc/Message/MessageReplyTracker.cs b/Utils/Phantom.Utils.Rpc/Message/MessageReplyTracker.cs index 852d1aa..47e6d6e 100644 --- a/Utils/Phantom.Utils.Rpc/Message/MessageReplyTracker.cs +++ b/Utils/Phantom.Utils.Rpc/Message/MessageReplyTracker.cs @@ -4,7 +4,7 @@ using Serilog; namespace Phantom.Utils.Rpc.Message; -public sealed class MessageReplyTracker { +sealed class MessageReplyTracker { private readonly ILogger logger; private readonly ConcurrentDictionary<uint, TaskCompletionSource<byte[]>> replyTasks = new (4, 16); diff --git a/Controller/Phantom.Controller.Rpc/RpcClientConnectionClosedEventArgs.cs b/Utils/Phantom.Utils.Rpc/Runtime/RpcClientConnectionClosedEventArgs.cs similarity index 54% rename from Controller/Phantom.Controller.Rpc/RpcClientConnectionClosedEventArgs.cs rename to Utils/Phantom.Utils.Rpc/Runtime/RpcClientConnectionClosedEventArgs.cs index 41c2e0f..4118ad2 100644 --- a/Controller/Phantom.Controller.Rpc/RpcClientConnectionClosedEventArgs.cs +++ b/Utils/Phantom.Utils.Rpc/Runtime/RpcClientConnectionClosedEventArgs.cs @@ -1,6 +1,6 @@ -namespace Phantom.Controller.Rpc; +namespace Phantom.Utils.Rpc.Runtime; -public sealed class RpcClientConnectionClosedEventArgs : EventArgs { +sealed class RpcClientConnectionClosedEventArgs : EventArgs { internal uint RoutingId { get; } internal RpcClientConnectionClosedEventArgs(uint routingId) { diff --git a/Utils/Phantom.Utils.Rpc/RpcClientRuntime.cs b/Utils/Phantom.Utils.Rpc/Runtime/RpcClientRuntime.cs similarity index 94% rename from Utils/Phantom.Utils.Rpc/RpcClientRuntime.cs rename to Utils/Phantom.Utils.Rpc/Runtime/RpcClientRuntime.cs index f234759..872851e 100644 --- a/Utils/Phantom.Utils.Rpc/RpcClientRuntime.cs +++ b/Utils/Phantom.Utils.Rpc/Runtime/RpcClientRuntime.cs @@ -5,7 +5,7 @@ using Phantom.Utils.Tasks; using Serilog; using Serilog.Events; -namespace Phantom.Utils.Rpc; +namespace Phantom.Utils.Rpc.Runtime; public abstract class RpcClientRuntime<TClientListener, TServerListener, TReplyMessage> : RpcRuntime<ClientSocket> where TReplyMessage : IMessage<TClientListener, NoReply>, IMessage<TServerListener, NoReply> { private readonly RpcConnectionToServer<TServerListener> connection; @@ -23,7 +23,7 @@ public abstract class RpcClientRuntime<TClientListener, TServerListener, TReplyM this.receiveCancellationToken = receiveCancellationToken; } - protected sealed override void Run(ClientSocket socket, ILogger logger, MessageReplyTracker replyTracker, TaskManager taskManager) { + private protected sealed override void Run(ClientSocket socket, ILogger logger, MessageReplyTracker replyTracker, TaskManager taskManager) { RunWithConnection(socket, connection, logger, taskManager); } diff --git a/Controller/Phantom.Controller.Rpc/RpcConnectionToClient.cs b/Utils/Phantom.Utils.Rpc/Runtime/RpcConnectionToClient.cs similarity index 98% rename from Controller/Phantom.Controller.Rpc/RpcConnectionToClient.cs rename to Utils/Phantom.Utils.Rpc/Runtime/RpcConnectionToClient.cs index 895c205..2f9f2f4 100644 --- a/Controller/Phantom.Controller.Rpc/RpcConnectionToClient.cs +++ b/Utils/Phantom.Utils.Rpc/Runtime/RpcConnectionToClient.cs @@ -2,7 +2,7 @@ using NetMQ.Sockets; using Phantom.Utils.Rpc.Message; -namespace Phantom.Controller.Rpc; +namespace Phantom.Utils.Rpc.Runtime; public sealed class RpcConnectionToClient<TListener> { private readonly ServerSocket socket; diff --git a/Utils/Phantom.Utils.Rpc/RpcConnectionToServer.cs b/Utils/Phantom.Utils.Rpc/Runtime/RpcConnectionToServer.cs similarity index 98% rename from Utils/Phantom.Utils.Rpc/RpcConnectionToServer.cs rename to Utils/Phantom.Utils.Rpc/Runtime/RpcConnectionToServer.cs index b160af9..9421047 100644 --- a/Utils/Phantom.Utils.Rpc/RpcConnectionToServer.cs +++ b/Utils/Phantom.Utils.Rpc/Runtime/RpcConnectionToServer.cs @@ -2,7 +2,7 @@ using NetMQ.Sockets; using Phantom.Utils.Rpc.Message; -namespace Phantom.Utils.Rpc; +namespace Phantom.Utils.Rpc.Runtime; public sealed class RpcConnectionToServer<TListener> { private readonly ClientSocket socket; diff --git a/Utils/Phantom.Utils.Rpc/RpcRuntime.cs b/Utils/Phantom.Utils.Rpc/Runtime/RpcRuntime.cs similarity index 88% rename from Utils/Phantom.Utils.Rpc/RpcRuntime.cs rename to Utils/Phantom.Utils.Rpc/Runtime/RpcRuntime.cs index 0474f97..49e73eb 100644 --- a/Utils/Phantom.Utils.Rpc/RpcRuntime.cs +++ b/Utils/Phantom.Utils.Rpc/Runtime/RpcRuntime.cs @@ -4,7 +4,7 @@ using Phantom.Utils.Rpc.Sockets; using Phantom.Utils.Tasks; using Serilog; -namespace Phantom.Utils.Rpc; +namespace Phantom.Utils.Rpc.Runtime; public abstract class RpcRuntime<TSocket> where TSocket : ThreadSafeSocket { private readonly TSocket socket; @@ -41,7 +41,7 @@ public abstract class RpcRuntime<TSocket> where TSocket : ThreadSafeSocket { } } - protected abstract void Run(TSocket socket, ILogger logger, MessageReplyTracker replyTracker, TaskManager taskManager); + private protected abstract void Run(TSocket socket, ILogger logger, MessageReplyTracker replyTracker, TaskManager taskManager); protected virtual Task Disconnect(TSocket socket, ILogger logger) { return Task.CompletedTask; diff --git a/Controller/Phantom.Controller.Rpc/RpcRuntime.cs b/Utils/Phantom.Utils.Rpc/Runtime/RpcServerRuntime.cs similarity index 81% rename from Controller/Phantom.Controller.Rpc/RpcRuntime.cs rename to Utils/Phantom.Utils.Rpc/Runtime/RpcServerRuntime.cs index 47e45b0..e7b4bef 100644 --- a/Controller/Phantom.Controller.Rpc/RpcRuntime.cs +++ b/Utils/Phantom.Utils.Rpc/Runtime/RpcServerRuntime.cs @@ -1,36 +1,35 @@ using NetMQ.Sockets; -using Phantom.Utils.Rpc; using Phantom.Utils.Rpc.Message; using Phantom.Utils.Rpc.Sockets; using Phantom.Utils.Tasks; using Serilog; using Serilog.Events; -namespace Phantom.Controller.Rpc; +namespace Phantom.Utils.Rpc.Runtime; -public static class RpcRuntime { +public static class RpcServerRuntime { public static Task Launch<TClientListener, TServerListener, TReplyMessage>(RpcConfiguration config, IMessageDefinitions<TClientListener, TServerListener, TReplyMessage> messageDefinitions, Func<RpcConnectionToClient<TClientListener>, TServerListener> listenerFactory, CancellationToken cancellationToken) where TReplyMessage : IMessage<TClientListener, NoReply>, IMessage<TServerListener, NoReply> { - return RpcRuntime<TClientListener, TServerListener, TReplyMessage>.Launch(config, messageDefinitions, listenerFactory, cancellationToken); + return RpcServerRuntime<TClientListener, TServerListener, TReplyMessage>.Launch(config, messageDefinitions, listenerFactory, cancellationToken); } } -internal sealed class RpcRuntime<TClientListener, TServerListener, TReplyMessage> : RpcRuntime<ServerSocket> where TReplyMessage : IMessage<TClientListener, NoReply>, IMessage<TServerListener, NoReply> { +internal sealed class RpcServerRuntime<TClientListener, TServerListener, TReplyMessage> : RpcRuntime<ServerSocket> where TReplyMessage : IMessage<TClientListener, NoReply>, IMessage<TServerListener, NoReply> { internal static Task Launch(RpcConfiguration config, IMessageDefinitions<TClientListener, TServerListener, TReplyMessage> messageDefinitions, Func<RpcConnectionToClient<TClientListener>, TServerListener> listenerFactory, CancellationToken cancellationToken) { var socket = RpcServerSocket.Connect(config); - return new RpcRuntime<TClientListener, TServerListener, TReplyMessage>(socket, messageDefinitions, listenerFactory, cancellationToken).Launch(); + return new RpcServerRuntime<TClientListener, TServerListener, TReplyMessage>(socket, messageDefinitions, listenerFactory, cancellationToken).Launch(); } private readonly IMessageDefinitions<TClientListener, TServerListener, TReplyMessage> messageDefinitions; private readonly Func<RpcConnectionToClient<TClientListener>, TServerListener> listenerFactory; private readonly CancellationToken cancellationToken; - private RpcRuntime(RpcServerSocket socket, IMessageDefinitions<TClientListener, TServerListener, TReplyMessage> messageDefinitions, Func<RpcConnectionToClient<TClientListener>, TServerListener> listenerFactory, CancellationToken cancellationToken) : base(socket) { + private RpcServerRuntime(RpcServerSocket socket, IMessageDefinitions<TClientListener, TServerListener, TReplyMessage> messageDefinitions, Func<RpcConnectionToClient<TClientListener>, TServerListener> listenerFactory, CancellationToken cancellationToken) : base(socket) { this.messageDefinitions = messageDefinitions; this.listenerFactory = listenerFactory; this.cancellationToken = cancellationToken; } - protected override void Run(ServerSocket socket, ILogger logger, MessageReplyTracker replyTracker, TaskManager taskManager) { + private protected override void Run(ServerSocket socket, ILogger logger, MessageReplyTracker replyTracker, TaskManager taskManager) { var clients = new Dictionary<ulong, Client>(); void OnConnectionClosed(object? sender, RpcClientConnectionClosedEventArgs e) { diff --git a/Utils/Phantom.Utils.Rpc/Sockets/RpcClientSocket.cs b/Utils/Phantom.Utils.Rpc/Sockets/RpcClientSocket.cs index f26bf95..13e9279 100644 --- a/Utils/Phantom.Utils.Rpc/Sockets/RpcClientSocket.cs +++ b/Utils/Phantom.Utils.Rpc/Sockets/RpcClientSocket.cs @@ -1,6 +1,7 @@ using NetMQ; using NetMQ.Sockets; using Phantom.Utils.Rpc.Message; +using Phantom.Utils.Rpc.Runtime; namespace Phantom.Utils.Rpc.Sockets; diff --git a/Web/Phantom.Web.Services/Rpc/ControllerConnection.cs b/Web/Phantom.Web.Services/Rpc/ControllerConnection.cs index a2e3d6f..2cc950e 100644 --- a/Web/Phantom.Web.Services/Rpc/ControllerConnection.cs +++ b/Web/Phantom.Web.Services/Rpc/ControllerConnection.cs @@ -1,5 +1,5 @@ using Phantom.Common.Messages.Web; -using Phantom.Utils.Rpc; +using Phantom.Utils.Rpc.Runtime; namespace Phantom.Web.Services.Rpc; diff --git a/Web/Phantom.Web.Services/Rpc/MessageListener.cs b/Web/Phantom.Web.Services/Rpc/MessageListener.cs index 6b821f4..b0e3fe8 100644 --- a/Web/Phantom.Web.Services/Rpc/MessageListener.cs +++ b/Web/Phantom.Web.Services/Rpc/MessageListener.cs @@ -1,8 +1,8 @@ using Phantom.Common.Messages.Web; using Phantom.Common.Messages.Web.BiDirectional; using Phantom.Common.Messages.Web.ToWeb; -using Phantom.Utils.Rpc; using Phantom.Utils.Rpc.Message; +using Phantom.Utils.Rpc.Runtime; using Phantom.Utils.Tasks; using Phantom.Web.Services.Agents; using Phantom.Web.Services.Instances; diff --git a/Web/Phantom.Web.Services/Rpc/RpcClientRuntime.cs b/Web/Phantom.Web.Services/Rpc/RpcClientRuntime.cs index 393265f..c35bfd7 100644 --- a/Web/Phantom.Web.Services/Rpc/RpcClientRuntime.cs +++ b/Web/Phantom.Web.Services/Rpc/RpcClientRuntime.cs @@ -3,7 +3,7 @@ using NetMQ.Sockets; using Phantom.Common.Messages.Web; using Phantom.Common.Messages.Web.BiDirectional; using Phantom.Common.Messages.Web.ToController; -using Phantom.Utils.Rpc; +using Phantom.Utils.Rpc.Runtime; using Phantom.Utils.Rpc.Sockets; using ILogger = Serilog.ILogger; diff --git a/Web/Phantom.Web/WebLauncher.cs b/Web/Phantom.Web/WebLauncher.cs index 42735b5..2217e35 100644 --- a/Web/Phantom.Web/WebLauncher.cs +++ b/Web/Phantom.Web/WebLauncher.cs @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.DataProtection; using Phantom.Common.Messages.Web; -using Phantom.Utils.Rpc; +using Phantom.Utils.Rpc.Runtime; using Phantom.Utils.Tasks; using Phantom.Web.Base; using Phantom.Web.Services;