From bcfb66a88d048dac47ac3b59e87c280533c040e0 Mon Sep 17 00:00:00 2001 From: Mikhail Mitrofanov Date: Tue, 18 Feb 2025 22:49:59 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=81=D0=B5=20=D0=B2=D0=B0=D1=80=D0=BD?= =?UTF-8?q?=D0=B8=D0=BD=D0=B3=D0=B8=20=D1=83=D0=B1=D1=80=D0=B0=D0=BD=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Backend/NetworkGatewayModule.cs | 19 +++++++++---------- mROA/Implementation/CallRequest.cs | 2 ++ .../TypedFinalCommandExecution.cs | 1 + 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/mROA/Implementation/Backend/NetworkGatewayModule.cs b/mROA/Implementation/Backend/NetworkGatewayModule.cs index 2146c0a..c62cfc1 100644 --- a/mROA/Implementation/Backend/NetworkGatewayModule.cs +++ b/mROA/Implementation/Backend/NetworkGatewayModule.cs @@ -8,9 +8,9 @@ public class NetworkGatewayModule : IGatewayModule { private readonly Type? _interactionModuleType; private readonly IInjectableModule[]? _injectableModules; - private readonly TcpListener? _tcpListener; + private readonly TcpListener _tcpListener; private IConnectionHub? _hub; - private ISerializationToolkit _serializationToolkit; + private ISerializationToolkit? _serialization; public NetworkGatewayModule(IPEndPoint endpoint, Type interactionModuleType, IInjectableModule[] injectableModules) { @@ -21,7 +21,7 @@ public class NetworkGatewayModule : IGatewayModule public void Run() { - _tcpListener!.Start(); + _tcpListener.Start(); Console.WriteLine($"Listening on {_tcpListener.LocalEndpoint}"); Console.WriteLine("Enter Backspace to stop"); @@ -47,16 +47,15 @@ public class NetworkGatewayModule : IGatewayModule { if (_hub is null) throw new NullReferenceException("Hub module is null"); - if (_tcpListener == null) throw new NullReferenceException("TcpListener is null"); - if (_injectableModules is null) throw new NullReferenceException("InjectableModules is null"); - if (_interactionModuleType is null) throw new NullReferenceException("InteractionModuleType is null"); - + if (_serialization is null) + throw new NullReferenceException("Serialization is null"); + while (true) { var client = _tcpListener.AcceptTcpClient(); @@ -66,14 +65,14 @@ public class NetworkGatewayModule : IGatewayModule foreach (var injectableModule in _injectableModules) interaction!.Inject(injectableModule); - interaction!.Inject(_serializationToolkit); + interaction!.Inject(_serialization); interaction.BaseStream = client.GetStream(); interaction.PostMessage(new NetworkMessage { Id = Guid.NewGuid(), SchemaId = MessageType.IdAssigning, - Data = _serializationToolkit.Serialize(new IdAssingnment { Id = interaction.ConnectionId }) + Data = _serialization.Serialize(new IdAssingnment { Id = interaction.ConnectionId }) }); _hub.RegisterInteraction(interaction); Console.WriteLine("Client registered"); @@ -85,6 +84,6 @@ public class NetworkGatewayModule : IGatewayModule if (dependency is IConnectionHub interactionModule) _hub = interactionModule; if (dependency is ISerializationToolkit serializationToolkit) - _serializationToolkit = serializationToolkit; + _serialization = serializationToolkit; } } \ No newline at end of file diff --git a/mROA/Implementation/CallRequest.cs b/mROA/Implementation/CallRequest.cs index 6ef0aeb..1709ba7 100644 --- a/mROA/Implementation/CallRequest.cs +++ b/mROA/Implementation/CallRequest.cs @@ -1,4 +1,6 @@ using System.Text.Json.Serialization; +// ReSharper disable UnusedAutoPropertyAccessor.Global +// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global namespace mROA.Implementation; diff --git a/mROA/Implementation/CommandExecution/TypedFinalCommandExecution.cs b/mROA/Implementation/CommandExecution/TypedFinalCommandExecution.cs index e408c94..813accc 100644 --- a/mROA/Implementation/CommandExecution/TypedFinalCommandExecution.cs +++ b/mROA/Implementation/CommandExecution/TypedFinalCommandExecution.cs @@ -5,5 +5,6 @@ namespace mROA.Implementation.CommandExecution; public class TypedFinalCommandExecution : FinalCommandExecution { [JsonIgnore] + // ReSharper disable once UnusedAutoPropertyAccessor.Global public Type? Type { get; set; } } \ No newline at end of file