2019-12-27 14:20:27 +00:00
|
|
|
using System;
|
2014-08-11 14:15:53 +00:00
|
|
|
using System.Threading.Tasks;
|
2017-10-04 18:51:26 +00:00
|
|
|
using MediaBrowser.Controller.Net;
|
2019-01-13 19:24:58 +00:00
|
|
|
using MediaBrowser.Model.Activity;
|
|
|
|
using MediaBrowser.Model.Events;
|
|
|
|
using Microsoft.Extensions.Logging;
|
2014-08-11 14:15:53 +00:00
|
|
|
|
|
|
|
namespace MediaBrowser.Api.System
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Class SessionInfoWebSocketListener
|
|
|
|
/// </summary>
|
2019-12-27 14:20:27 +00:00
|
|
|
public class ActivityLogWebSocketListener : BasePeriodicWebSocketListener<ActivityLogEntry[], WebSocketListenerState>
|
2014-08-11 14:15:53 +00:00
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the name.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The name.</value>
|
2019-01-13 20:31:14 +00:00
|
|
|
protected override string Name => "ActivityLogEntry";
|
2014-08-11 14:15:53 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The _kernel
|
|
|
|
/// </summary>
|
|
|
|
private readonly IActivityManager _activityManager;
|
|
|
|
|
2020-03-03 22:07:10 +00:00
|
|
|
public ActivityLogWebSocketListener(ILogger<ActivityLogWebSocketListener> logger, IActivityManager activityManager) : base(logger)
|
2014-08-11 14:15:53 +00:00
|
|
|
{
|
|
|
|
_activityManager = activityManager;
|
2019-12-27 14:20:27 +00:00
|
|
|
_activityManager.EntryCreated += OnEntryCreated;
|
2014-08-11 14:15:53 +00:00
|
|
|
}
|
|
|
|
|
2019-12-27 14:20:27 +00:00
|
|
|
private void OnEntryCreated(object sender, GenericEventArgs<ActivityLogEntry> e)
|
2014-08-11 14:15:53 +00:00
|
|
|
{
|
|
|
|
SendData(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the data to send.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>Task{SystemInfo}.</returns>
|
2019-12-27 14:20:27 +00:00
|
|
|
protected override Task<ActivityLogEntry[]> GetDataToSend()
|
2014-08-11 14:15:53 +00:00
|
|
|
{
|
2019-12-27 14:20:27 +00:00
|
|
|
return Task.FromResult(Array.Empty<ActivityLogEntry>());
|
2014-08-11 14:15:53 +00:00
|
|
|
}
|
2019-01-07 23:27:46 +00:00
|
|
|
|
2019-12-27 14:20:27 +00:00
|
|
|
/// <inheritdoc />
|
2014-08-11 14:15:53 +00:00
|
|
|
protected override void Dispose(bool dispose)
|
|
|
|
{
|
2019-12-27 14:20:27 +00:00
|
|
|
_activityManager.EntryCreated -= OnEntryCreated;
|
2014-08-11 14:15:53 +00:00
|
|
|
|
|
|
|
base.Dispose(dispose);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|