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