jellyfin/MediaBrowser.Api/System/ActivityLogWebSocketListener.cs

66 lines
1.9 KiB
C#
Raw Normal View History

2016-10-31 20:07:45 -07:00
using MediaBrowser.Model.Activity;
2014-08-11 07:15:53 -07:00
using MediaBrowser.Model.Events;
using MediaBrowser.Model.Logging;
using System.Collections.Generic;
using System.Threading.Tasks;
2016-10-31 20:07:45 -07:00
using MediaBrowser.Model.Threading;
2014-08-11 07:15:53 -07:00
namespace MediaBrowser.Api.System
{
/// <summary>
/// Class SessionInfoWebSocketListener
/// </summary>
class ActivityLogWebSocketListener : BasePeriodicWebSocketListener<List<ActivityLogEntry>, WebSocketListenerState>
{
/// <summary>
/// Gets the name.
/// </summary>
/// <value>The name.</value>
protected override string Name
{
get { return "ActivityLogEntry"; }
}
/// <summary>
/// The _kernel
/// </summary>
private readonly IActivityManager _activityManager;
2016-10-31 20:07:45 -07:00
public ActivityLogWebSocketListener(ILogger logger, ITimerFactory timerFactory, IActivityManager activityManager) : base(logger, timerFactory)
2014-08-11 07:15:53 -07:00
{
_activityManager = activityManager;
_activityManager.EntryCreated += _activityManager_EntryCreated;
}
void _activityManager_EntryCreated(object sender, GenericEventArgs<ActivityLogEntry> e)
{
SendData(true);
}
/// <summary>
/// Gets the data to send.
/// </summary>
/// <param name="state">The state.</param>
/// <returns>Task{SystemInfo}.</returns>
protected override Task<List<ActivityLogEntry>> GetDataToSend(WebSocketListenerState state)
{
return Task.FromResult(new List<ActivityLogEntry>());
}
protected override bool SendOnTimer
{
get
{
return false;
}
}
protected override void Dispose(bool dispose)
{
_activityManager.EntryCreated -= _activityManager_EntryCreated;
base.Dispose(dispose);
}
}
}