diff options
Diffstat (limited to 'Jellyfin.Api/WebSocketListeners/SessionInfoWebSocketListener.cs')
| -rw-r--r-- | Jellyfin.Api/WebSocketListeners/SessionInfoWebSocketListener.cs | 60 |
1 files changed, 28 insertions, 32 deletions
diff --git a/Jellyfin.Api/WebSocketListeners/SessionInfoWebSocketListener.cs b/Jellyfin.Api/WebSocketListeners/SessionInfoWebSocketListener.cs index ab9f789a1..1fb5dc412 100644 --- a/Jellyfin.Api/WebSocketListeners/SessionInfoWebSocketListener.cs +++ b/Jellyfin.Api/WebSocketListeners/SessionInfoWebSocketListener.cs @@ -12,20 +12,13 @@ namespace Jellyfin.Api.WebSocketListeners /// </summary> public class SessionInfoWebSocketListener : BasePeriodicWebSocketListener<IEnumerable<SessionInfo>, WebSocketListenerState> { - /// <summary> - /// Gets the name. - /// </summary> - /// <value>The name.</value> - protected override string Name => "Sessions"; - - /// <summary> - /// The _kernel. - /// </summary> private readonly ISessionManager _sessionManager; /// <summary> /// Initializes a new instance of the <see cref="SessionInfoWebSocketListener"/> class. /// </summary> + /// <param name="logger">Instance of the <see cref="ILogger{SessionInfoWebSocketListener}"/> interface.</param> + /// <param name="sessionManager">Instance of the <see cref="ISessionManager"/> interface.</param> public SessionInfoWebSocketListener(ILogger<SessionInfoWebSocketListener> logger, ISessionManager sessionManager) : base(logger) { @@ -40,6 +33,32 @@ namespace Jellyfin.Api.WebSocketListeners _sessionManager.SessionActivity += OnSessionManagerSessionActivity; } + /// <inheritdoc /> + protected override string Name => "Sessions"; + + /// <summary> + /// Gets the data to send. + /// </summary> + /// <returns>Task{SystemInfo}.</returns> + protected override Task<IEnumerable<SessionInfo>> GetDataToSend() + { + return Task.FromResult(_sessionManager.Sessions); + } + + /// <inheritdoc /> + protected override void Dispose(bool dispose) + { + _sessionManager.SessionStarted -= OnSessionManagerSessionStarted; + _sessionManager.SessionEnded -= OnSessionManagerSessionEnded; + _sessionManager.PlaybackStart -= OnSessionManagerPlaybackStart; + _sessionManager.PlaybackStopped -= OnSessionManagerPlaybackStopped; + _sessionManager.PlaybackProgress -= OnSessionManagerPlaybackProgress; + _sessionManager.CapabilitiesChanged -= OnSessionManagerCapabilitiesChanged; + _sessionManager.SessionActivity -= OnSessionManagerSessionActivity; + + base.Dispose(dispose); + } + private async void OnSessionManagerSessionActivity(object sender, SessionEventArgs e) { await SendData(false).ConfigureAwait(false); @@ -74,28 +93,5 @@ namespace Jellyfin.Api.WebSocketListeners { await SendData(true).ConfigureAwait(false); } - - /// <summary> - /// Gets the data to send. - /// </summary> - /// <returns>Task{SystemInfo}.</returns> - protected override Task<IEnumerable<SessionInfo>> GetDataToSend() - { - return Task.FromResult(_sessionManager.Sessions); - } - - /// <inheritdoc /> - protected override void Dispose(bool dispose) - { - _sessionManager.SessionStarted -= OnSessionManagerSessionStarted; - _sessionManager.SessionEnded -= OnSessionManagerSessionEnded; - _sessionManager.PlaybackStart -= OnSessionManagerPlaybackStart; - _sessionManager.PlaybackStopped -= OnSessionManagerPlaybackStopped; - _sessionManager.PlaybackProgress -= OnSessionManagerPlaybackProgress; - _sessionManager.CapabilitiesChanged -= OnSessionManagerCapabilitiesChanged; - _sessionManager.SessionActivity -= OnSessionManagerSessionActivity; - - base.Dispose(dispose); - } } } |
