diff --git a/MareSynchronos/MareSynchronos.json b/MareSynchronos/MareSynchronos.json index 82addc0..317ce25 100644 --- a/MareSynchronos/MareSynchronos.json +++ b/MareSynchronos/MareSynchronos.json @@ -9,6 +9,5 @@ "customization" ], "IconUrl": "https://raw.githubusercontent.com/Penumbra-Sync/client/main/MareSynchronos/images/logo.png", - "RepoUrl": "https://github.com/Penumbra-Sync/client", - "CanUnloadAsync": true + "RepoUrl": "https://github.com/Penumbra-Sync/client" } \ No newline at end of file diff --git a/MareSynchronos/PlayerData/Factories/PairHandlerFactory.cs b/MareSynchronos/PlayerData/Factories/PairHandlerFactory.cs index 4c96117..f9ee5f6 100644 --- a/MareSynchronos/PlayerData/Factories/PairHandlerFactory.cs +++ b/MareSynchronos/PlayerData/Factories/PairHandlerFactory.cs @@ -5,6 +5,7 @@ using MareSynchronos.PlayerData.Handlers; using MareSynchronos.PlayerData.Pairs; using MareSynchronos.Services; using MareSynchronos.Services.Mediator; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace MareSynchronos.PlayerData.Factories; @@ -15,7 +16,7 @@ public class PairHandlerFactory private readonly FileCacheManager _fileCacheManager; private readonly FileDownloadManagerFactory _fileDownloadManagerFactory; private readonly GameObjectHandlerFactory _gameObjectHandlerFactory; - private readonly CancellationToken _dalamudLifetimeToken; + private readonly IHostApplicationLifetime _hostApplicationLifetime; private readonly IpcManager _ipcManager; private readonly ILoggerFactory _loggerFactory; private readonly MareMediator _mareMediator; @@ -23,7 +24,7 @@ public class PairHandlerFactory public PairHandlerFactory(ILoggerFactory loggerFactory, GameObjectHandlerFactory gameObjectHandlerFactory, IpcManager ipcManager, FileDownloadManagerFactory fileDownloadManagerFactory, DalamudUtilService dalamudUtilService, - PluginWarningNotificationService pluginWarningNotificationManager, CancellationToken dalamudLifetime, + PluginWarningNotificationService pluginWarningNotificationManager, IHostApplicationLifetime hostApplicationLifetime, FileCacheManager fileCacheManager, MareMediator mareMediator) { _loggerFactory = loggerFactory; @@ -32,7 +33,7 @@ public class PairHandlerFactory _fileDownloadManagerFactory = fileDownloadManagerFactory; _dalamudUtilService = dalamudUtilService; _pluginWarningNotificationManager = pluginWarningNotificationManager; - _dalamudLifetimeToken = dalamudLifetime; + _hostApplicationLifetime = hostApplicationLifetime; _fileCacheManager = fileCacheManager; _mareMediator = mareMediator; } @@ -40,7 +41,7 @@ public class PairHandlerFactory public PairHandler Create(OnlineUserIdentDto onlineUserIdentDto) { return new PairHandler(_loggerFactory.CreateLogger(), onlineUserIdentDto, _gameObjectHandlerFactory, - _ipcManager, _fileDownloadManagerFactory.Create(), _pluginWarningNotificationManager, _dalamudUtilService, _dalamudLifetimeToken, + _ipcManager, _fileDownloadManagerFactory.Create(), _pluginWarningNotificationManager, _dalamudUtilService, _hostApplicationLifetime, _fileCacheManager, _mareMediator); } } \ No newline at end of file diff --git a/MareSynchronos/PlayerData/Handlers/PairHandler.cs b/MareSynchronos/PlayerData/Handlers/PairHandler.cs index 5fbf94b..115f830 100644 --- a/MareSynchronos/PlayerData/Handlers/PairHandler.cs +++ b/MareSynchronos/PlayerData/Handlers/PairHandler.cs @@ -9,6 +9,7 @@ using MareSynchronos.Services.Events; using MareSynchronos.Services.Mediator; using MareSynchronos.Utils; using MareSynchronos.WebAPI.Files; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using System.Collections.Concurrent; using System.Diagnostics; @@ -25,7 +26,7 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase private readonly FileCacheManager _fileDbManager; private readonly GameObjectHandlerFactory _gameObjectHandlerFactory; private readonly IpcManager _ipcManager; - private readonly CancellationToken _lifetime; + private readonly IHostApplicationLifetime _lifetime; private readonly PluginWarningNotificationService _pluginWarningNotificationManager; private CancellationTokenSource? _applicationCancellationTokenSource = new(); private Guid _applicationId; @@ -44,7 +45,7 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase GameObjectHandlerFactory gameObjectHandlerFactory, IpcManager ipcManager, FileDownloadManager transferManager, PluginWarningNotificationService pluginWarningNotificationManager, - DalamudUtilService dalamudUtil, CancellationToken lifetime, + DalamudUtilService dalamudUtil, IHostApplicationLifetime lifetime, FileCacheManager fileDbManager, MareMediator mediator) : base(logger, mediator) { OnlineUser = onlineUser; @@ -232,7 +233,7 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase Mediator.Publish(new EventMessage(new Event(name, OnlineUser.User, nameof(PairHandler), EventSeverity.Informational, "Disposing User"))); } - if (_lifetime.IsCancellationRequested) return; + if (_lifetime.ApplicationStopping.IsCancellationRequested) return; if (_dalamudUtil is { IsZoning: false, IsInCutscene: false } && !string.IsNullOrEmpty(name)) { diff --git a/MareSynchronos/Plugin.cs b/MareSynchronos/Plugin.cs index 7b6c31b..13c1974 100644 --- a/MareSynchronos/Plugin.cs +++ b/MareSynchronos/Plugin.cs @@ -66,11 +66,7 @@ public sealed class Plugin : IDalamudPlugin collection.AddSingleton(); collection.AddSingleton(); collection.AddSingleton(); - collection.AddSingleton((s) => new PairHandlerFactory(s.GetRequiredService(), s.GetRequiredService(), - s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService(), - s.GetRequiredService(), - CancellationTokenSource.CreateLinkedTokenSource(addonLifecycle.GameShuttingDownToken, addonLifecycle.DalamudUnloadingToken).Token, - s.GetRequiredService(), s.GetRequiredService())); + collection.AddSingleton(); collection.AddSingleton(); collection.AddSingleton(); collection.AddSingleton();