using MediaBrowser.Common.Net;
using MediaBrowser.Common.ScheduledTasks;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Logging;
using System.Threading.Tasks;
namespace MediaBrowser.WebDashboard.Api
{
///
/// Class DashboardInfoWebSocketListener
///
class DashboardInfoWebSocketListener : BasePeriodicWebSocketListener
{
///
/// Gets the name.
///
/// The name.
protected override string Name
{
get { return "DashboardInfo"; }
}
private readonly IServerApplicationHost _appHost;
///
/// Gets or sets the task manager.
///
/// The task manager.
private readonly ITaskManager _taskManager;
private readonly ISessionManager _sessionManager;
private readonly IDtoService _dtoService;
///
/// Initializes a new instance of the class.
///
/// The app host.
/// The logger.
/// The task manager.
/// The session manager.
public DashboardInfoWebSocketListener(IServerApplicationHost appHost, ILogger logger, ITaskManager taskManager, ISessionManager sessionManager, IDtoService dtoService)
: base(logger)
{
_appHost = appHost;
_taskManager = taskManager;
_sessionManager = sessionManager;
_dtoService = dtoService;
}
///
/// Gets the data to send.
///
/// The state.
/// Task{IEnumerable{TaskInfo}}.
protected override Task GetDataToSend(object state)
{
return Task.FromResult(DashboardService.GetDashboardInfo(_appHost, _taskManager, _sessionManager, _dtoService));
}
}
}