2013-02-21 02:33:05 +01:00
|
|
|
|
using MediaBrowser.Common.Kernel;
|
|
|
|
|
using MediaBrowser.Common.ScheduledTasks;
|
2013-02-21 21:26:35 +01:00
|
|
|
|
using MediaBrowser.Model.Logging;
|
2013-02-21 02:33:05 +01:00
|
|
|
|
using MediaBrowser.Model.Tasks;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
2013-02-22 05:23:06 +01:00
|
|
|
|
namespace MediaBrowser.Api.ScheduledTasks
|
2013-02-21 02:33:05 +01:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class ScheduledTasksWebSocketListener
|
|
|
|
|
/// </summary>
|
2013-02-22 16:16:48 +01:00
|
|
|
|
public class ScheduledTasksWebSocketListener : BasePeriodicWebSocketListener<IEnumerable<TaskInfo>, object>
|
2013-02-21 02:33:05 +01:00
|
|
|
|
{
|
2013-02-23 08:57:11 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the task manager.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The task manager.</value>
|
|
|
|
|
private ITaskManager TaskManager { get; set; }
|
|
|
|
|
|
2013-02-21 02:33:05 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the name.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The name.</value>
|
|
|
|
|
protected override string Name
|
|
|
|
|
{
|
|
|
|
|
get { return "ScheduledTasksInfo"; }
|
|
|
|
|
}
|
2013-02-21 21:26:35 +01:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initializes a new instance of the <see cref="ScheduledTasksWebSocketListener" /> class.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="logger">The logger.</param>
|
2013-02-23 08:57:11 +01:00
|
|
|
|
/// <param name="taskManager">The task manager.</param>
|
|
|
|
|
public ScheduledTasksWebSocketListener(ILogger logger, ITaskManager taskManager)
|
2013-02-21 21:26:35 +01:00
|
|
|
|
: base(logger)
|
|
|
|
|
{
|
2013-02-23 08:57:11 +01:00
|
|
|
|
TaskManager = taskManager;
|
2013-02-21 21:26:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-21 02:33:05 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the data to send.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="state">The state.</param>
|
|
|
|
|
/// <returns>Task{IEnumerable{TaskInfo}}.</returns>
|
|
|
|
|
protected override Task<IEnumerable<TaskInfo>> GetDataToSend(object state)
|
|
|
|
|
{
|
2013-02-23 08:57:11 +01:00
|
|
|
|
return Task.FromResult(TaskManager.ScheduledTasks.OrderBy(i => i.Name)
|
2013-02-21 02:33:05 +01:00
|
|
|
|
.Select(ScheduledTaskHelpers.GetTaskInfo));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|