using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Activity;
using MediaBrowser.Model.Events;
using Microsoft.Extensions.Logging;
namespace MediaBrowser.Api.System
{
///
/// Class SessionInfoWebSocketListener
///
class ActivityLogWebSocketListener : BasePeriodicWebSocketListener, WebSocketListenerState>
{
///
/// Gets the name.
///
/// The name.
protected override string Name
{
get { return "ActivityLogEntry"; }
}
///
/// The _kernel
///
private readonly IActivityManager _activityManager;
public ActivityLogWebSocketListener(ILogger logger, IActivityManager activityManager) : base(logger)
{
_activityManager = activityManager;
_activityManager.EntryCreated += _activityManager_EntryCreated;
}
void _activityManager_EntryCreated(object sender, GenericEventArgs e)
{
SendData(true);
}
///
/// Gets the data to send.
///
/// The state.
/// Task{SystemInfo}.
protected override Task> GetDataToSend(WebSocketListenerState state, CancellationToken CancellationToken)
{
return Task.FromResult(new List());
}
protected override void Dispose(bool dispose)
{
_activityManager.EntryCreated -= _activityManager_EntryCreated;
base.Dispose(dispose);
}
}
}