2013-03-07 06:34:00 +01:00
|
|
|
|
using MediaBrowser.Common.Net;
|
2013-02-23 08:57:11 +01:00
|
|
|
|
using MediaBrowser.Common.ScheduledTasks;
|
2013-02-21 02:33:05 +01:00
|
|
|
|
using MediaBrowser.Controller;
|
2013-02-27 21:25:45 +01:00
|
|
|
|
using MediaBrowser.Controller.Library;
|
2013-05-09 19:38:02 +02:00
|
|
|
|
using MediaBrowser.Controller.Session;
|
2013-02-21 21:26:35 +01:00
|
|
|
|
using MediaBrowser.Model.Logging;
|
2013-02-21 02:33:05 +01:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.WebDashboard.Api
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class DashboardInfoWebSocketListener
|
|
|
|
|
/// </summary>
|
2013-02-22 16:16:48 +01:00
|
|
|
|
class DashboardInfoWebSocketListener : BasePeriodicWebSocketListener<DashboardInfo, object>
|
2013-02-21 02:33:05 +01:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the name.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The name.</value>
|
|
|
|
|
protected override string Name
|
|
|
|
|
{
|
|
|
|
|
get { return "DashboardInfo"; }
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-07 06:34:00 +01:00
|
|
|
|
private readonly IServerApplicationHost _appHost;
|
2013-02-22 16:16:48 +01:00
|
|
|
|
|
2013-02-23 08:57:11 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the task manager.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The task manager.</value>
|
|
|
|
|
private readonly ITaskManager _taskManager;
|
|
|
|
|
|
2013-05-09 19:38:02 +02:00
|
|
|
|
private readonly ISessionManager _sessionManager;
|
2013-02-27 21:25:45 +01:00
|
|
|
|
|
2013-02-21 21:26:35 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initializes a new instance of the <see cref="DashboardInfoWebSocketListener" /> class.
|
|
|
|
|
/// </summary>
|
2013-04-03 04:59:27 +02:00
|
|
|
|
/// <param name="appHost">The app host.</param>
|
2013-02-21 21:26:35 +01:00
|
|
|
|
/// <param name="logger">The logger.</param>
|
2013-02-27 21:25:45 +01:00
|
|
|
|
/// <param name="taskManager">The task manager.</param>
|
2013-06-19 14:24:50 +02:00
|
|
|
|
/// <param name="sessionManager">The session manager.</param>
|
|
|
|
|
public DashboardInfoWebSocketListener(IServerApplicationHost appHost, ILogger logger, ITaskManager taskManager, ISessionManager sessionManager)
|
2013-02-21 21:26:35 +01:00
|
|
|
|
: base(logger)
|
|
|
|
|
{
|
2013-03-07 06:34:00 +01:00
|
|
|
|
_appHost = appHost;
|
2013-02-23 08:57:11 +01:00
|
|
|
|
_taskManager = taskManager;
|
2013-05-09 19:38:02 +02:00
|
|
|
|
_sessionManager = sessionManager;
|
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<DashboardInfo> GetDataToSend(object state)
|
|
|
|
|
{
|
2013-06-19 14:24:50 +02:00
|
|
|
|
return Task.FromResult(DashboardService.GetDashboardInfo(_appHost, _taskManager, _sessionManager));
|
2013-02-21 02:33:05 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|