using System;
using System.Threading.Tasks;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Activity;
using MediaBrowser.Model.Events;
using Microsoft.Extensions.Logging;
namespace Jellyfin.Api.WebSocketListeners
{
///
/// Class SessionInfoWebSocketListener.
///
public class ActivityLogWebSocketListener : BasePeriodicWebSocketListener
{
///
/// The _kernel.
///
private readonly IActivityManager _activityManager;
///
/// Initializes a new instance of the class.
///
/// Instance of the interface.
/// Instance of the interface.
public ActivityLogWebSocketListener(ILogger logger, IActivityManager activityManager)
: base(logger)
{
_activityManager = activityManager;
_activityManager.EntryCreated += OnEntryCreated;
}
///
/// Gets the name.
///
/// The name.
protected override string Name => "ActivityLogEntry";
///
/// 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);
}
private void OnEntryCreated(object sender, GenericEventArgs e)
{
SendData(true);
}
}
}