Merge pull request #4710 from OancaAndrei/syncplay-fix-session-restore

Restore sessions in SyncPlay groups upon reconnection
This commit is contained in:
Claus Vium 2020-12-11 09:57:14 +01:00 committed by GitHub
commit a57e465de9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 3 deletions

View File

@ -128,6 +128,9 @@ namespace Emby.Server.Implementations.Session
/// <inheritdoc />
public event EventHandler<SessionEventArgs> SessionActivity;
/// <inheritdoc />
public event EventHandler<SessionEventArgs> SessionControllerConnected;
/// <summary>
/// Gets all connections.
/// </summary>
@ -312,6 +315,19 @@ namespace Emby.Server.Implementations.Session
return session;
}
/// <inheritdoc />
public void OnSessionControllerConnected(SessionInfo info)
{
EventHelper.QueueEventIfNotNull(
SessionControllerConnected,
this,
new SessionEventArgs
{
SessionInfo = info
},
_logger);
}
/// <inheritdoc />
public void CloseIfNeeded(SessionInfo session)
{

View File

@ -133,6 +133,8 @@ namespace Emby.Server.Implementations.Session
var controller = (WebSocketController)controllerInfo.Item1;
controller.AddWebSocket(connection);
_sessionManager.OnSessionControllerConnected(session);
}
/// <summary>

View File

@ -81,7 +81,7 @@ namespace Emby.Server.Implementations.SyncPlay
_sessionManager = sessionManager;
_libraryManager = libraryManager;
_logger = loggerFactory.CreateLogger<SyncPlayManager>();
_sessionManager.SessionStarted += OnSessionManagerSessionStarted;
_sessionManager.SessionControllerConnected += OnSessionControllerConnected;
}
/// <inheritdoc />
@ -329,11 +329,11 @@ namespace Emby.Server.Implementations.SyncPlay
return;
}
_sessionManager.SessionStarted -= OnSessionManagerSessionStarted;
_sessionManager.SessionControllerConnected -= OnSessionControllerConnected;
_disposed = true;
}
private void OnSessionManagerSessionStarted(object sender, SessionEventArgs e)
private void OnSessionControllerConnected(object sender, SessionEventArgs e)
{
var session = e.SessionInfo;

View File

@ -46,6 +46,11 @@ namespace MediaBrowser.Controller.Session
event EventHandler<SessionEventArgs> SessionActivity;
/// <summary>
/// Occurs when [session controller connected].
/// </summary>
event EventHandler<SessionEventArgs> SessionControllerConnected;
/// <summary>
/// Occurs when [capabilities changed].
/// </summary>
@ -78,6 +83,12 @@ namespace MediaBrowser.Controller.Session
/// <param name="user">The user.</param>
SessionInfo LogSessionActivity(string appName, string appVersion, string deviceId, string deviceName, string remoteEndPoint, Jellyfin.Data.Entities.User user);
/// <summary>
/// Used to report that a session controller has connected.
/// </summary>
/// <param name="session">The session.</param>
void OnSessionControllerConnected(SessionInfo session);
void UpdateDeviceName(string sessionId, string reportedDeviceName);
/// <summary>