Merge pull request #18 from BoxuChan/main

Code Optimizations for SignalR/ApiController
This commit is contained in:
2025-09-06 15:08:24 +01:00
committed by GitHub

View File

@@ -310,7 +310,7 @@ public sealed partial class ApiController : DisposableMediatorSubscriberBase, IM
_ = Task.Run(async () => await StopConnection(ServerState.Disconnected).ConfigureAwait(false));
_connectionCancellationTokenSource?.Cancel();
}
private int _unhealthy = 0;
private async Task ClientHealthCheck(CancellationToken ct)
{
while (!ct.IsCancellationRequested && _mareHub != null)
@@ -318,17 +318,11 @@ public sealed partial class ApiController : DisposableMediatorSubscriberBase, IM
await Task.Delay(TimeSpan.FromSeconds(30), ct).ConfigureAwait(false);
var healthy = await CheckClientHealth().ConfigureAwait(false);
if (!healthy || _mareHub.State != HubConnectionState.Connected)
{
_unhealthy++;
if (_unhealthy > 0)
{
Logger.LogWarning("Health check failed, forcing reconnect. ClientHealth: {0} HubConnected: {1}", healthy, _mareHub.State != HubConnectionState.Connected);
await ForceResetConnection().ConfigureAwait(false);
_unhealthy = 0;
}
}
else _unhealthy = 0;
}
}
private void DalamudUtilOnLogIn()