Merge pull request #5903 from iwalton3/auto-leave-syncplay

Leave SyncPlay group on session disconnect.
pull/5934/head
Bond-009 4 years ago committed by GitHub
commit dcc2df75ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -87,7 +87,7 @@ namespace Emby.Server.Implementations.SyncPlay
_sessionManager = sessionManager; _sessionManager = sessionManager;
_libraryManager = libraryManager; _libraryManager = libraryManager;
_logger = loggerFactory.CreateLogger<SyncPlayManager>(); _logger = loggerFactory.CreateLogger<SyncPlayManager>();
_sessionManager.SessionControllerConnected += OnSessionControllerConnected; _sessionManager.SessionEnded += OnSessionEnded;
} }
/// <inheritdoc /> /// <inheritdoc />
@ -352,18 +352,18 @@ namespace Emby.Server.Implementations.SyncPlay
return; return;
} }
_sessionManager.SessionControllerConnected -= OnSessionControllerConnected; _sessionManager.SessionEnded -= OnSessionEnded;
_disposed = true; _disposed = true;
} }
private void OnSessionControllerConnected(object sender, SessionEventArgs e) private void OnSessionEnded(object sender, SessionEventArgs e)
{ {
var session = e.SessionInfo; var session = e.SessionInfo;
if (_sessionToGroupMap.TryGetValue(session.Id, out var group)) if (_sessionToGroupMap.TryGetValue(session.Id, out var group))
{ {
var request = new JoinGroupRequest(group.GroupId); var leaveGroupRequest = new LeaveGroupRequest();
JoinGroup(session, request, CancellationToken.None); LeaveGroup(session, leaveGroupRequest, CancellationToken.None);
} }
} }

Loading…
Cancel
Save