using MediaBrowser.Common.Net;
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, WebSocketListenerState>
{
///
/// 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(WebSocketListenerState state)
{
return Task.FromResult(_sessionManager.Sessions.Where(i => i.IsActive).Select(_sessionManager.GetSessionInfoDto));
}
}
}