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

Leave SyncPlay group on session disconnect.
This commit is contained in:
Bond-009 2021-04-29 14:19:07 +02:00 committed by GitHub
commit dcc2df75ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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