diff options
| author | Patrick Barron <barronpm@gmail.com> | 2020-08-15 18:16:41 -0400 |
|---|---|---|
| committer | Patrick Barron <barronpm@gmail.com> | 2020-08-15 18:16:41 -0400 |
| commit | 5282a5c8c2224ec36121cdf99ef2a14f7d703973 (patch) | |
| tree | 38cc2def3b7c9c498acd257a222668d636520b24 | |
| parent | a0453a0fe65d19d0484cc83ce2f31b08dadcfd09 (diff) | |
Migrate ServerEventNotifier.OnTaskCompleted to IEventConsumer
| -rw-r--r-- | Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs | 17 | ||||
| -rw-r--r-- | Jellyfin.Server.Implementations/Events/Consumers/System/TaskCompletedNotifier.cs | 31 |
2 files changed, 31 insertions, 17 deletions
diff --git a/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs b/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs index 0e5086685..833c06106 100644 --- a/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs +++ b/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs @@ -25,11 +25,6 @@ namespace Emby.Server.Implementations.EntryPoints /// </summary> private readonly IServerApplicationHost _appHost; - /// <summary> - /// The task manager. - /// </summary> - private readonly ITaskManager _taskManager; - private readonly ISessionManager _sessionManager; /// <summary> @@ -37,17 +32,14 @@ namespace Emby.Server.Implementations.EntryPoints /// </summary> /// <param name="appHost">The application host.</param> /// <param name="installationManager">The installation manager.</param> - /// <param name="taskManager">The task manager.</param> /// <param name="sessionManager">The session manager.</param> public ServerEventNotifier( IServerApplicationHost appHost, IInstallationManager installationManager, - ITaskManager taskManager, ISessionManager sessionManager) { _installationManager = installationManager; _appHost = appHost; - _taskManager = taskManager; _sessionManager = sessionManager; } @@ -62,8 +54,6 @@ namespace Emby.Server.Implementations.EntryPoints _installationManager.PackageInstallationCompleted += OnPackageInstallationCompleted; _installationManager.PackageInstallationFailed += OnPackageInstallationFailed; - _taskManager.TaskCompleted += OnTaskCompleted; - return Task.CompletedTask; } @@ -87,11 +77,6 @@ namespace Emby.Server.Implementations.EntryPoints await SendMessageToAdminSessions("PackageInstallationFailed", e.InstallationInfo).ConfigureAwait(false); } - private async void OnTaskCompleted(object sender, TaskCompletionEventArgs e) - { - await SendMessageToAdminSessions("ScheduledTaskEnded", e.Result).ConfigureAwait(false); - } - /// <summary> /// Installations the manager_ plugin uninstalled. /// </summary> @@ -145,8 +130,6 @@ namespace Emby.Server.Implementations.EntryPoints _installationManager.PackageInstallationFailed -= OnPackageInstallationFailed; _appHost.HasPendingRestartChanged -= OnHasPendingRestartChanged; - - _taskManager.TaskCompleted -= OnTaskCompleted; } } } diff --git a/Jellyfin.Server.Implementations/Events/Consumers/System/TaskCompletedNotifier.cs b/Jellyfin.Server.Implementations/Events/Consumers/System/TaskCompletedNotifier.cs new file mode 100644 index 000000000..80ed56cd8 --- /dev/null +++ b/Jellyfin.Server.Implementations/Events/Consumers/System/TaskCompletedNotifier.cs @@ -0,0 +1,31 @@ +using System.Threading; +using System.Threading.Tasks; +using MediaBrowser.Controller.Events; +using MediaBrowser.Controller.Session; +using MediaBrowser.Model.Tasks; + +namespace Jellyfin.Server.Implementations.Events.Consumers.System +{ + /// <summary> + /// Notifies admin users when a task is completed. + /// </summary> + public class TaskCompletedNotifier : IEventConsumer<TaskCompletionEventArgs> + { + private readonly ISessionManager _sessionManager; + + /// <summary> + /// Initializes a new instance of the <see cref="TaskCompletedNotifier"/> class. + /// </summary> + /// <param name="sessionManager">The session manager.</param> + public TaskCompletedNotifier(ISessionManager sessionManager) + { + _sessionManager = sessionManager; + } + + /// <inheritdoc /> + public async Task OnEvent(TaskCompletionEventArgs eventArgs) + { + await _sessionManager.SendMessageToAdminSessions("ScheduledTaskEnded", eventArgs.Result, CancellationToken.None).ConfigureAwait(false); + } + } +} |
