From 3f92cc0f6488221aaf4c75240e37b1b1e5b9acd1 Mon Sep 17 00:00:00 2001 From: Mikhail Mitrofanov Date: Wed, 9 Apr 2025 21:21:08 +0300 Subject: [PATCH] Fix infinitive reconnection --- mROA.Test/NextGenTest.cs | 4 +++- mROA/Implementation/Backend/NetworkGatewayModule.cs | 2 ++ mROA/Implementation/NextGenerationInteractionModule.cs | 6 +++++- mROA/mROA.csproj | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/mROA.Test/NextGenTest.cs b/mROA.Test/NextGenTest.cs index 31e2347..0b708a7 100644 --- a/mROA.Test/NextGenTest.cs +++ b/mROA.Test/NextGenTest.cs @@ -13,7 +13,7 @@ namespace mROA.Test private TcpListener _listener; private NextGenerationInteractionModule _interactionModuleA; private NextGenerationInteractionModule _interactionModuleB; - private Guid[] guids = new[] { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() }; + private Guid[] guids = [Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()]; [SetUp] public void Setup() @@ -72,6 +72,8 @@ namespace mROA.Test { _listener.Stop(); _listener.Dispose(); + _interactionModuleA.Dispose(); + _interactionModuleB.Dispose(); } } } \ No newline at end of file diff --git a/mROA/Implementation/Backend/NetworkGatewayModule.cs b/mROA/Implementation/Backend/NetworkGatewayModule.cs index cee7453..a3236a8 100644 --- a/mROA/Implementation/Backend/NetworkGatewayModule.cs +++ b/mROA/Implementation/Backend/NetworkGatewayModule.cs @@ -87,6 +87,8 @@ namespace mROA.Implementation.Backend break; case EMessageType.ClientRecovery: { + + interaction.BaseStream = null; var recoveryRequest = _serialization!.Deserialize(connectionRequest.Data)!; var recoveryInteraction = _hub.GetInteraction(recoveryRequest.Id); recoveryInteraction.BaseStream = client.GetStream(); diff --git a/mROA/Implementation/NextGenerationInteractionModule.cs b/mROA/Implementation/NextGenerationInteractionModule.cs index e9d3a27..57ba7dd 100644 --- a/mROA/Implementation/NextGenerationInteractionModule.cs +++ b/mROA/Implementation/NextGenerationInteractionModule.cs @@ -257,8 +257,12 @@ namespace mROA.Implementation public void Dispose() { + Console.WriteLine("Interaction module disposed"); _isActive = false; - _currentReceiving?.Dispose(); + if (_currentReceiving is { IsCompleted: true }) + { + _currentReceiving?.Dispose(); + } _baseStream?.Dispose(); } } diff --git a/mROA/mROA.csproj b/mROA/mROA.csproj index 7be3a6c..5c9aea9 100644 --- a/mROA/mROA.csproj +++ b/mROA/mROA.csproj @@ -21,7 +21,7 @@ - TRACE; +