2019-01-13 13:01:16 -07:00
|
|
|
using System.Collections.Generic;
|
2019-01-13 12:24:58 -07:00
|
|
|
using System.Threading;
|
2014-08-11 07:15:53 -07:00
|
|
|
using System.Threading.Tasks;
|
2017-10-04 11:51:26 -07:00
|
|
|
using MediaBrowser.Controller.Net;
|
2019-01-13 12:24:58 -07:00
|
|
|
using MediaBrowser.Model.Activity;
|
|
|
|
using MediaBrowser.Model.Events;
|
|
|
|
using Microsoft.Extensions.Logging;
|
2014-08-11 07:15:53 -07:00
|
|
|
|
|
|
|
namespace MediaBrowser.Api.System
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Class SessionInfoWebSocketListener
|
|
|
|
/// </summary>
|
2019-02-15 15:05:14 -07:00
|
|
|
public class ActivityLogWebSocketListener : BasePeriodicWebSocketListener<List<ActivityLogEntry>, WebSocketListenerState>
|
2014-08-11 07:15:53 -07:00
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the name.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The name.</value>
|
2019-01-13 13:31:14 -07:00
|
|
|
protected override string Name => "ActivityLogEntry";
|
2014-08-11 07:15:53 -07:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The _kernel
|
|
|
|
/// </summary>
|
|
|
|
private readonly IActivityManager _activityManager;
|
|
|
|
|
2018-09-12 10:26:21 -07:00
|
|
|
public ActivityLogWebSocketListener(ILogger logger, IActivityManager activityManager) : base(logger)
|
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>
|
|
|
|
/// <returns>Task{SystemInfo}.</returns>
|
2019-02-27 14:09:22 -07:00
|
|
|
protected override Task<List<ActivityLogEntry>> GetDataToSend()
|
2014-08-11 07:15:53 -07:00
|
|
|
{
|
|
|
|
return Task.FromResult(new List<ActivityLogEntry>());
|
|
|
|
}
|
2019-01-07 16:27:46 -07:00
|
|
|
|
2014-08-11 07:15:53 -07:00
|
|
|
|
|
|
|
protected override void Dispose(bool dispose)
|
|
|
|
{
|
|
|
|
_activityManager.EntryCreated -= _activityManager_EntryCreated;
|
|
|
|
|
|
|
|
base.Dispose(dispose);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|