mirror of
https://github.com/Caraxi/mare.client.git
synced 2025-12-12 17:57:21 +01:00
don't check for updated token during zoning
This commit is contained in:
parent
681a4e1d2a
commit
88d0ab2d99
2 changed files with 13 additions and 2 deletions
|
|
@ -673,7 +673,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
|||
_lastZone = zone;
|
||||
if (!_sentBetweenAreas)
|
||||
{
|
||||
_logger.LogDebug("Zone switch/Gpose start");
|
||||
_logger.LogDebug("Zone switch start");
|
||||
_sentBetweenAreas = true;
|
||||
Mediator.Publish(new ZoneSwitchStartMessage());
|
||||
Mediator.Publish(new HaltScanMessage(nameof(ConditionFlag.BetweenAreas)));
|
||||
|
|
@ -685,7 +685,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
|||
|
||||
if (_sentBetweenAreas)
|
||||
{
|
||||
_logger.LogDebug("Zone switch/Gpose end");
|
||||
_logger.LogDebug("Zone switch end");
|
||||
_sentBetweenAreas = false;
|
||||
Mediator.Publish(new ZoneSwitchEndMessage());
|
||||
Mediator.Publish(new ResumeScanMessage(nameof(ConditionFlag.BetweenAreas)));
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ public sealed partial class ApiController : DisposableMediatorSubscriberBase, IM
|
|||
private HubConnection? _mareHub;
|
||||
private ServerState _serverState;
|
||||
private CensusUpdateMessage? _lastCensus;
|
||||
private readonly SemaphoreSlim _zoneSwitchSemaphore = new(1, 1);
|
||||
|
||||
public ApiController(ILogger<ApiController> logger, HubFactory hubFactory, DalamudUtilService dalamudUtil,
|
||||
PairManager pairManager, ServerConfigurationManager serverManager, MareMediator mediator,
|
||||
|
|
@ -60,6 +61,8 @@ public sealed partial class ApiController : DisposableMediatorSubscriberBase, IM
|
|||
Mediator.Subscribe<CyclePauseMessage>(this, (msg) => _ = CyclePauseAsync(msg.UserData));
|
||||
Mediator.Subscribe<CensusUpdateMessage>(this, (msg) => _lastCensus = msg);
|
||||
Mediator.Subscribe<PauseMessage>(this, (msg) => _ = PauseAsync(msg.UserData));
|
||||
Mediator.Subscribe<ZoneSwitchStartMessage>(this, (msg) => _zoneSwitchSemaphore.Wait());
|
||||
Mediator.Subscribe<ZoneSwitchEndMessage>(this, (msg) => _zoneSwitchSemaphore.Release());
|
||||
|
||||
ServerState = ServerState.Offline;
|
||||
|
||||
|
|
@ -363,6 +366,7 @@ public sealed partial class ApiController : DisposableMediatorSubscriberBase, IM
|
|||
|
||||
_healthCheckTokenSource?.Cancel();
|
||||
_ = Task.Run(async () => await StopConnectionAsync(ServerState.Disconnected).ConfigureAwait(false));
|
||||
_zoneSwitchSemaphore.Dispose();
|
||||
_connectionCancellationTokenSource?.Cancel();
|
||||
}
|
||||
|
||||
|
|
@ -532,6 +536,13 @@ public sealed partial class ApiController : DisposableMediatorSubscriberBase, IM
|
|||
|
||||
private async Task<bool> RefreshTokenAsync(CancellationToken ct)
|
||||
{
|
||||
int zoneSwitchWaitAttempts = 0;
|
||||
while (_zoneSwitchSemaphore.CurrentCount == 0 && zoneSwitchWaitAttempts <= 15)
|
||||
{
|
||||
Logger.LogTrace("Refresh Token - Waiting for Zone Switch Semaphore, attempt {attempt}", zoneSwitchWaitAttempts++);
|
||||
await Task.Delay(TimeSpan.FromSeconds(1), ct).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
Logger.LogDebug("Checking token");
|
||||
|
||||
bool requireReconnect = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue