Additional interaction module stopping
This commit is contained in:
@@ -5,7 +5,7 @@ using mROA.Implementation;
|
|||||||
|
|
||||||
namespace mROA.Abstract
|
namespace mROA.Abstract
|
||||||
{
|
{
|
||||||
public interface INextGenerationInteractionModule : IInjectableModule
|
public interface INextGenerationInteractionModule : IInjectableModule, IDisposable
|
||||||
{
|
{
|
||||||
int ConnectionId { get; set; }
|
int ConnectionId { get; set; }
|
||||||
public Stream? BaseStream { get; set; }
|
public Stream? BaseStream { get; set; }
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ namespace mROA.Implementation.Frontend
|
|||||||
public void Disconnect()
|
public void Disconnect()
|
||||||
{
|
{
|
||||||
_ = _interactionModule!.PostMessageAsync(new NetworkMessageHeader(_serialization!, new ClientDisconnect()));
|
_ = _interactionModule!.PostMessageAsync(new NetworkMessageHeader(_serialization!, new ClientDisconnect()));
|
||||||
_interactionModule.BaseStream!.Close();
|
_interactionModule.Dispose();
|
||||||
_tcpClient.Dispose();
|
_tcpClient.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ namespace mROA.Implementation
|
|||||||
{
|
{
|
||||||
public class NetworkMessageHeader
|
public class NetworkMessageHeader
|
||||||
{
|
{
|
||||||
|
public static readonly NetworkMessageHeader Null = new();
|
||||||
public NetworkMessageHeader()
|
public NetworkMessageHeader()
|
||||||
{
|
{
|
||||||
Id = Guid.NewGuid();
|
Id = Guid.NewGuid();
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ namespace mROA.Implementation
|
|||||||
private Stream? _baseStream;
|
private Stream? _baseStream;
|
||||||
private bool _isConnected = true;
|
private bool _isConnected = true;
|
||||||
private bool _isInReconnectionState;
|
private bool _isInReconnectionState;
|
||||||
|
private bool _isActive = true;
|
||||||
private TaskCompletionSource<Stream> _reconnection;
|
private TaskCompletionSource<Stream> _reconnection;
|
||||||
|
|
||||||
public NextGenerationInteractionModule()
|
public NextGenerationInteractionModule()
|
||||||
@@ -96,6 +97,10 @@ namespace mROA.Implementation
|
|||||||
if (await PostMessageInternal(messageHeader))
|
if (await PostMessageInternal(messageHeader))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
if (!_isActive)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
_isConnected = false;
|
_isConnected = false;
|
||||||
withError = true;
|
withError = true;
|
||||||
await MakeRecovery("OUT");
|
await MakeRecovery("OUT");
|
||||||
@@ -142,6 +147,10 @@ namespace mROA.Implementation
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
if (!_isActive)
|
||||||
|
{
|
||||||
|
return NetworkMessageHeader.Null;
|
||||||
|
}
|
||||||
withError = true;
|
withError = true;
|
||||||
await MakeRecovery("IN");
|
await MakeRecovery("IN");
|
||||||
}
|
}
|
||||||
@@ -245,5 +254,12 @@ namespace mROA.Implementation
|
|||||||
_isInReconnectionState = false;
|
_isInReconnectionState = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_isActive = false;
|
||||||
|
_currentReceiving?.Dispose();
|
||||||
|
_baseStream?.Dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user