Migrate ServerEventNotifier.OnTaskCompleted to IEventConsumer
This commit is contained in:
parent
a0453a0fe6
commit
5282a5c8c2
|
@ -25,11 +25,6 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly IServerApplicationHost _appHost;
|
private readonly IServerApplicationHost _appHost;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The task manager.
|
|
||||||
/// </summary>
|
|
||||||
private readonly ITaskManager _taskManager;
|
|
||||||
|
|
||||||
private readonly ISessionManager _sessionManager;
|
private readonly ISessionManager _sessionManager;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -37,17 +32,14 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="appHost">The application host.</param>
|
/// <param name="appHost">The application host.</param>
|
||||||
/// <param name="installationManager">The installation manager.</param>
|
/// <param name="installationManager">The installation manager.</param>
|
||||||
/// <param name="taskManager">The task manager.</param>
|
|
||||||
/// <param name="sessionManager">The session manager.</param>
|
/// <param name="sessionManager">The session manager.</param>
|
||||||
public ServerEventNotifier(
|
public ServerEventNotifier(
|
||||||
IServerApplicationHost appHost,
|
IServerApplicationHost appHost,
|
||||||
IInstallationManager installationManager,
|
IInstallationManager installationManager,
|
||||||
ITaskManager taskManager,
|
|
||||||
ISessionManager sessionManager)
|
ISessionManager sessionManager)
|
||||||
{
|
{
|
||||||
_installationManager = installationManager;
|
_installationManager = installationManager;
|
||||||
_appHost = appHost;
|
_appHost = appHost;
|
||||||
_taskManager = taskManager;
|
|
||||||
_sessionManager = sessionManager;
|
_sessionManager = sessionManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,8 +54,6 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||||
_installationManager.PackageInstallationCompleted += OnPackageInstallationCompleted;
|
_installationManager.PackageInstallationCompleted += OnPackageInstallationCompleted;
|
||||||
_installationManager.PackageInstallationFailed += OnPackageInstallationFailed;
|
_installationManager.PackageInstallationFailed += OnPackageInstallationFailed;
|
||||||
|
|
||||||
_taskManager.TaskCompleted += OnTaskCompleted;
|
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,11 +77,6 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||||
await SendMessageToAdminSessions("PackageInstallationFailed", e.InstallationInfo).ConfigureAwait(false);
|
await SendMessageToAdminSessions("PackageInstallationFailed", e.InstallationInfo).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void OnTaskCompleted(object sender, TaskCompletionEventArgs e)
|
|
||||||
{
|
|
||||||
await SendMessageToAdminSessions("ScheduledTaskEnded", e.Result).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Installations the manager_ plugin uninstalled.
|
/// Installations the manager_ plugin uninstalled.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -145,8 +130,6 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||||
_installationManager.PackageInstallationFailed -= OnPackageInstallationFailed;
|
_installationManager.PackageInstallationFailed -= OnPackageInstallationFailed;
|
||||||
|
|
||||||
_appHost.HasPendingRestartChanged -= OnHasPendingRestartChanged;
|
_appHost.HasPendingRestartChanged -= OnHasPendingRestartChanged;
|
||||||
|
|
||||||
_taskManager.TaskCompleted -= OnTaskCompleted;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user