mirror of
https://github.com/Caraxi/mare.client.git
synced 2025-12-13 16:24:14 +01:00
delay honorific changes to avoid serverspam
This commit is contained in:
parent
ff73c016eb
commit
28b89f66f8
1 changed files with 16 additions and 1 deletions
|
|
@ -17,6 +17,7 @@ public sealed class CacheCreationService : DisposableMediatorSubscriberBase
|
||||||
private readonly CharacterData _playerData = new();
|
private readonly CharacterData _playerData = new();
|
||||||
private readonly Dictionary<ObjectKind, GameObjectHandler> _playerRelatedObjects = new();
|
private readonly Dictionary<ObjectKind, GameObjectHandler> _playerRelatedObjects = new();
|
||||||
private Task? _cacheCreationTask;
|
private Task? _cacheCreationTask;
|
||||||
|
private CancellationTokenSource _honorificCts = new();
|
||||||
private CancellationTokenSource _palettePlusCts = new();
|
private CancellationTokenSource _palettePlusCts = new();
|
||||||
|
|
||||||
public CacheCreationService(ILogger<CacheCreationService> logger, MareMediator mediator, Func<ObjectKind, Func<IntPtr>, bool, GameObjectHandler> gameObjectHandlerFactory,
|
public CacheCreationService(ILogger<CacheCreationService> logger, MareMediator mediator, Func<ObjectKind, Func<IntPtr>, bool, GameObjectHandler> gameObjectHandlerFactory,
|
||||||
|
|
@ -64,7 +65,7 @@ public sealed class CacheCreationService : DisposableMediatorSubscriberBase
|
||||||
Mediator.Subscribe<HonorificMessage>(this, async (_) =>
|
Mediator.Subscribe<HonorificMessage>(this, async (_) =>
|
||||||
{
|
{
|
||||||
Logger.LogDebug("Received Honorific change, updating player");
|
Logger.LogDebug("Received Honorific change, updating player");
|
||||||
await AddPlayerCacheToCreate().ConfigureAwait(false);
|
HonorificChanged();
|
||||||
});
|
});
|
||||||
Mediator.Subscribe<PenumbraModSettingChangedMessage>(this, async (msg) =>
|
Mediator.Subscribe<PenumbraModSettingChangedMessage>(this, async (msg) =>
|
||||||
{
|
{
|
||||||
|
|
@ -97,6 +98,20 @@ public sealed class CacheCreationService : DisposableMediatorSubscriberBase
|
||||||
_cacheCreateLock.Release();
|
_cacheCreateLock.Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void HonorificChanged()
|
||||||
|
{
|
||||||
|
_honorificCts?.Cancel();
|
||||||
|
_honorificCts?.Dispose();
|
||||||
|
_honorificCts = new();
|
||||||
|
var token = _honorificCts.Token;
|
||||||
|
|
||||||
|
Task.Run(async () =>
|
||||||
|
{
|
||||||
|
await Task.Delay(TimeSpan.FromSeconds(3), token).ConfigureAwait(false);
|
||||||
|
await AddPlayerCacheToCreate().ConfigureAwait(false);
|
||||||
|
}, token);
|
||||||
|
}
|
||||||
|
|
||||||
private void PalettePlusChanged()
|
private void PalettePlusChanged()
|
||||||
{
|
{
|
||||||
_palettePlusCts?.Cancel();
|
_palettePlusCts?.Cancel();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue