Cleaning of registry, fixed typo in object kind as it should be companion in the companion kind.
This commit is contained in:
@@ -1622,7 +1622,7 @@ internal sealed class PairHandlerAdapter : DisposableMediatorSubscriberBase, IPa
|
|||||||
if (companion != nint.Zero)
|
if (companion != nint.Zero)
|
||||||
{
|
{
|
||||||
await _ipcManager.CustomizePlus.RevertByIdAsync(customizeId).ConfigureAwait(false);
|
await _ipcManager.CustomizePlus.RevertByIdAsync(customizeId).ConfigureAwait(false);
|
||||||
using GameObjectHandler tempHandler = await _gameObjectHandlerFactory.Create(ObjectKind.Pet, () => companion, isWatched: false).ConfigureAwait(false);
|
using GameObjectHandler tempHandler = await _gameObjectHandlerFactory.Create(ObjectKind.Companion, () => companion, isWatched: false).ConfigureAwait(false);
|
||||||
await _ipcManager.Glamourer.RevertAsync(Logger, tempHandler, applicationId, cancelToken).ConfigureAwait(false);
|
await _ipcManager.Glamourer.RevertAsync(Logger, tempHandler, applicationId, cancelToken).ConfigureAwait(false);
|
||||||
await _ipcManager.Penumbra.RedrawAsync(Logger, tempHandler, applicationId, cancelToken).ConfigureAwait(false);
|
await _ipcManager.Penumbra.RedrawAsync(Logger, tempHandler, applicationId, cancelToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
@@ -1848,5 +1848,4 @@ internal sealed class PairHandlerAdapter : DisposableMediatorSubscriberBase, IPa
|
|||||||
ApplyCharacterData(pending.ApplicationId,
|
ApplyCharacterData(pending.ApplicationId,
|
||||||
pending.CharacterData, pending.Forced);
|
pending.CharacterData, pending.Forced);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public sealed class PairHandlerRegistry : IDisposable
|
|||||||
private readonly object _gate = new();
|
private readonly object _gate = new();
|
||||||
private readonly object _pendingGate = new();
|
private readonly object _pendingGate = new();
|
||||||
private readonly Dictionary<string, PairHandlerEntry> _entriesByIdent = new(StringComparer.Ordinal);
|
private readonly Dictionary<string, PairHandlerEntry> _entriesByIdent = new(StringComparer.Ordinal);
|
||||||
private readonly Dictionary<IPairHandlerAdapter, PairHandlerEntry> _entriesByHandler = new();
|
private readonly Dictionary<IPairHandlerAdapter, PairHandlerEntry> _entriesByHandler = new(ReferenceEqualityComparer.Instance);
|
||||||
|
|
||||||
private readonly IPairHandlerAdapterFactory _handlerFactory;
|
private readonly IPairHandlerAdapterFactory _handlerFactory;
|
||||||
private readonly PairManager _pairManager;
|
private readonly PairManager _pairManager;
|
||||||
@@ -162,7 +162,13 @@ public sealed class PairHandlerRegistry : IDisposable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handler.ApplyData(dto.CharaData);
|
if (!handler.Initialized)
|
||||||
|
{
|
||||||
|
handler.Initialize();
|
||||||
|
QueuePendingCharacterData(registration, dto);
|
||||||
|
return PairOperationResult.Ok();
|
||||||
|
}
|
||||||
|
|
||||||
return PairOperationResult.Ok();
|
return PairOperationResult.Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,25 +391,20 @@ public sealed class PairHandlerRegistry : IDisposable
|
|||||||
|
|
||||||
private void QueuePendingCharacterData(PairRegistration registration, OnlineUserCharaDataDto dto)
|
private void QueuePendingCharacterData(PairRegistration registration, OnlineUserCharaDataDto dto)
|
||||||
{
|
{
|
||||||
if (registration.CharacterIdent is null)
|
if (registration.CharacterIdent is null) return;
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CancellationTokenSource? previous = null;
|
CancellationTokenSource? previous;
|
||||||
CancellationTokenSource cts;
|
CancellationTokenSource cts;
|
||||||
|
|
||||||
lock (_pendingGate)
|
lock (_pendingGate)
|
||||||
{
|
{
|
||||||
if (_pendingCharacterData.TryGetValue(registration.CharacterIdent, out previous))
|
_pendingCharacterData.TryGetValue(registration.CharacterIdent, out previous);
|
||||||
{
|
previous?.Cancel();
|
||||||
previous.Cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
cts = new CancellationTokenSource();
|
cts = new CancellationTokenSource();
|
||||||
_pendingCharacterData[registration.CharacterIdent] = cts;
|
_pendingCharacterData[registration.CharacterIdent] = cts;
|
||||||
}
|
}
|
||||||
|
|
||||||
previous?.Dispose();
|
|
||||||
cts.CancelAfter(_handlerReadyTimeout);
|
cts.CancelAfter(_handlerReadyTimeout);
|
||||||
_ = Task.Run(() => WaitThenApplyPendingCharacterDataAsync(registration, dto, cts.Token, cts));
|
_ = Task.Run(() => WaitThenApplyPendingCharacterDataAsync(registration, dto, cts.Token, cts));
|
||||||
}
|
}
|
||||||
@@ -414,16 +415,10 @@ public sealed class PairHandlerRegistry : IDisposable
|
|||||||
lock (_pendingGate)
|
lock (_pendingGate)
|
||||||
{
|
{
|
||||||
if (_pendingCharacterData.TryGetValue(ident, out cts))
|
if (_pendingCharacterData.TryGetValue(ident, out cts))
|
||||||
{
|
|
||||||
_pendingCharacterData.Remove(ident);
|
_pendingCharacterData.Remove(ident);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (cts is not null)
|
cts?.Cancel();
|
||||||
{
|
|
||||||
cts.Cancel();
|
|
||||||
cts.Dispose();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CancelAllPendingCharacterData()
|
private void CancelAllPendingCharacterData()
|
||||||
@@ -433,21 +428,13 @@ public sealed class PairHandlerRegistry : IDisposable
|
|||||||
{
|
{
|
||||||
if (_pendingCharacterData.Count > 0)
|
if (_pendingCharacterData.Count > 0)
|
||||||
{
|
{
|
||||||
snapshot = _pendingCharacterData.Values.ToList();
|
snapshot = [.. _pendingCharacterData.Values];
|
||||||
_pendingCharacterData.Clear();
|
_pendingCharacterData.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (snapshot is null)
|
if (snapshot is null) return;
|
||||||
{
|
foreach (var cts in snapshot) cts.Cancel();
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var cts in snapshot)
|
|
||||||
{
|
|
||||||
cts.Cancel();
|
|
||||||
cts.Dispose();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task WaitThenApplyPendingCharacterDataAsync(
|
private async Task WaitThenApplyPendingCharacterDataAsync(
|
||||||
|
|||||||
Reference in New Issue
Block a user