add events

This commit is contained in:
rootdarkarchon
2023-12-23 16:59:51 +01:00
parent 532d88ed4c
commit 01ac0e476b
12 changed files with 448 additions and 3 deletions

View File

@@ -135,6 +135,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();
@@ -419,6 +421,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<bool> RefreshToken(CancellationToken ct)
@@ -464,6 +469,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());