using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Session;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace MediaBrowser.Api.WebSocket
{
///
/// Class SessionInfoWebSocketListener
///
class SessionInfoWebSocketListener : BasePeriodicWebSocketListener, object>
{
///
/// Gets the name.
///
/// The name.
protected override string Name
{
get { return "Sessions"; }
}
///
/// The _kernel
///
private readonly ISessionManager _sessionManager;
///
/// Initializes a new instance of the class.
///
/// The logger.
/// The session manager.
public SessionInfoWebSocketListener(ILogger logger, ISessionManager sessionManager)
: base(logger)
{
_sessionManager = sessionManager;
}
///
/// Gets the data to send.
///
/// The state.
/// Task{SystemInfo}.
protected override Task> GetDataToSend(object state)
{
return Task.FromResult(_sessionManager.Sessions.Select(SessionInfoDtoBuilder.GetSessionInfoDto));
}
}
}