add events

This commit is contained in:
rootdarkarchon
2023-12-23 16:59:51 +01:00
committed by Loporrit
parent c48520b6cd
commit e8ae2a6152
13 changed files with 442 additions and 4 deletions

View File

@@ -128,6 +128,8 @@ public sealed partial class ApiController : DisposableMediatorSubscriberBase, IM
await StopConnection(ServerState.Disconnected).ConfigureAwait(false);
Logger.LogInformation("Recreating Connection");
Mediator.Publish(new EventMessage(new Services.Events.Event(nameof(ApiController), Services.Events.EventSeverity.Informational,
$"Starting Connection to {_serverManager.CurrentServer.ServerName}")));
_connectionCancellationTokenSource.Cancel();
_connectionCancellationTokenSource = new CancellationTokenSource();
@@ -411,6 +413,9 @@ public sealed partial class ApiController : DisposableMediatorSubscriberBase, IM
_healthCheckTokenSource?.Cancel();
ServerState = ServerState.Reconnecting;
Logger.LogWarning(arg, "Connection closed... Reconnecting");
Mediator.Publish(new EventMessage(new Services.Events.Event(nameof(ApiController), Services.Events.EventSeverity.Warning,
$"Connection interrupted, reconnecting to {_serverManager.CurrentServer.ServerName}")));
}
private async Task StopConnection(ServerState state)
@@ -422,6 +427,9 @@ public sealed partial class ApiController : DisposableMediatorSubscriberBase, IM
if (_mareHub is not null)
{
Mediator.Publish(new EventMessage(new Services.Events.Event(nameof(ApiController), Services.Events.EventSeverity.Informational,
$"Stopping existing connection to {_serverManager.CurrentServer.ServerName}")));
_initialized = false;
_healthCheckTokenSource?.Cancel();
Mediator.Publish(new DisconnectedMessage());