using System;
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.
///
public class ActivityLogWebSocketListener : BasePeriodicWebSocketListener
{
///
/// Gets the name.
///
/// The name.
protected override string Name => "ActivityLogEntry";
///
/// The _kernel.
///
private readonly IActivityManager _activityManager;
public ActivityLogWebSocketListener(ILogger logger, IActivityManager activityManager) : base(logger)
{
_activityManager = activityManager;
_activityManager.EntryCreated += OnEntryCreated;
}
private void OnEntryCreated(object sender, GenericEventArgs e)
{
SendData(true);
}
///
/// Gets the data to send.
///
/// Task{SystemInfo}.
protected override Task GetDataToSend()
{
return Task.FromResult(Array.Empty());
}
///
protected override void Dispose(bool dispose)
{
_activityManager.EntryCreated -= OnEntryCreated;
base.Dispose(dispose);
}
}
}