jellyfin/MediaBrowser.Api/WebSocket/SessionInfoWebSocketListener.cs

56 lines
1.7 KiB
C#
Raw Normal View History

2013-05-31 03:38:46 +00:00
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
{
/// <summary>
/// Class SessionInfoWebSocketListener
/// </summary>
class SessionInfoWebSocketListener : BasePeriodicWebSocketListener<IEnumerable<SessionInfoDto>, object>
{
2013-09-04 17:02:19 +00:00
private readonly IDtoService _dtoService;
2013-05-31 03:38:46 +00:00
/// <summary>
/// Gets the name.
/// </summary>
/// <value>The name.</value>
protected override string Name
{
get { return "Sessions"; }
}
/// <summary>
/// The _kernel
/// </summary>
private readonly ISessionManager _sessionManager;
/// <summary>
/// Initializes a new instance of the <see cref="SessionInfoWebSocketListener"/> class.
/// </summary>
/// <param name="logger">The logger.</param>
/// <param name="sessionManager">The session manager.</param>
2013-09-04 17:02:19 +00:00
public SessionInfoWebSocketListener(ILogger logger, ISessionManager sessionManager, IDtoService dtoService)
2013-05-31 03:38:46 +00:00
: base(logger)
{
_sessionManager = sessionManager;
2013-09-04 17:02:19 +00:00
_dtoService = dtoService;
2013-05-31 03:38:46 +00:00
}
/// <summary>
/// Gets the data to send.
/// </summary>
/// <param name="state">The state.</param>
/// <returns>Task{SystemInfo}.</returns>
protected override Task<IEnumerable<SessionInfoDto>> GetDataToSend(object state)
{
2013-09-04 17:02:19 +00:00
return Task.FromResult(_sessionManager.Sessions.Select(_dtoService.GetSessionInfoDto));
2013-05-31 03:38:46 +00:00
}
}
}