jellyfin/MediaBrowser.Api/WebSocket/SystemInfoWebSocketListener.cs
2014-05-10 13:28:03 -04:00

50 lines
1.5 KiB
C#

using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.System;
using System.Threading.Tasks;
namespace MediaBrowser.Api.WebSocket
{
/// <summary>
/// Class SystemInfoWebSocketListener
/// </summary>
public class SystemInfoWebSocketListener : BasePeriodicWebSocketListener<SystemInfo, WebSocketListenerState>
{
/// <summary>
/// Gets the name.
/// </summary>
/// <value>The name.</value>
protected override string Name
{
get { return "SystemInfo"; }
}
/// <summary>
/// The _kernel
/// </summary>
private readonly IServerApplicationHost _appHost;
/// <summary>
/// Initializes a new instance of the <see cref="SystemInfoWebSocketListener" /> class.
/// </summary>
/// <param name="logger">The logger.</param>
/// <param name="appHost">The app host.</param>
public SystemInfoWebSocketListener(ILogger logger, IServerApplicationHost appHost)
: base(logger)
{
_appHost = appHost;
}
/// <summary>
/// Gets the data to send.
/// </summary>
/// <param name="state">The state.</param>
/// <returns>Task{SystemInfo}.</returns>
protected override Task<SystemInfo> GetDataToSend(WebSocketListenerState state)
{
return Task.FromResult(_appHost.GetSystemInfo());
}
}
}