mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-07-22 21:50:36 +02:00
Close live stream on session end
This commit is contained in:
parent
8a6b26cd42
commit
bf0a7c374c
|
@ -329,13 +329,17 @@ namespace Emby.Server.Implementations.Session
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void CloseIfNeeded(SessionInfo session)
|
public async Task CloseIfNeededAsync(SessionInfo session)
|
||||||
{
|
{
|
||||||
if (!session.SessionControllers.Any(i => i.IsSessionActive))
|
if (!session.SessionControllers.Any(i => i.IsSessionActive))
|
||||||
{
|
{
|
||||||
var key = GetSessionKey(session.Client, session.DeviceId);
|
var key = GetSessionKey(session.Client, session.DeviceId);
|
||||||
|
|
||||||
_activeConnections.TryRemove(key, out _);
|
_activeConnections.TryRemove(key, out _);
|
||||||
|
if (!string.IsNullOrEmpty(session.PlayState?.LiveStreamId))
|
||||||
|
{
|
||||||
|
await _mediaSourceManager.CloseLiveStream(session.PlayState?.LiveStreamId).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
OnSessionEnded(session);
|
OnSessionEnded(session);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,13 +53,13 @@ namespace Emby.Server.Implementations.Session
|
||||||
connection.Closed += OnConnectionClosed;
|
connection.Closed += OnConnectionClosed;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnConnectionClosed(object? sender, EventArgs e)
|
private async void OnConnectionClosed(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var connection = sender as IWebSocketConnection ?? throw new ArgumentException($"{nameof(sender)} is not of type {nameof(IWebSocketConnection)}", nameof(sender));
|
var connection = sender as IWebSocketConnection ?? throw new ArgumentException($"{nameof(sender)} is not of type {nameof(IWebSocketConnection)}", nameof(sender));
|
||||||
_logger.LogDebug("Removing websocket from session {Session}", _session.Id);
|
_logger.LogDebug("Removing websocket from session {Session}", _session.Id);
|
||||||
_sockets.Remove(connection);
|
_sockets.Remove(connection);
|
||||||
connection.Closed -= OnConnectionClosed;
|
connection.Closed -= OnConnectionClosed;
|
||||||
_sessionManager.CloseIfNeeded(_session);
|
await _sessionManager.CloseIfNeededAsync(_session).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|
|
@ -352,6 +352,6 @@ namespace MediaBrowser.Controller.Session
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
Task RevokeUserTokens(Guid userId, string currentAccessToken);
|
Task RevokeUserTokens(Guid userId, string currentAccessToken);
|
||||||
|
|
||||||
void CloseIfNeeded(SessionInfo session);
|
Task CloseIfNeededAsync(SessionInfo session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue