From 16b9d26ab5e52c3c72dd24f17587ca4775ff79dd Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 3 Oct 2013 14:02:23 -0400 Subject: fixes #273 - Marking/unmarking Favorite status doesn't cause a library changed notification --- .../Session/SessionManager.cs | 62 ++++++++++++++++++++-- 1 file changed, 59 insertions(+), 3 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Session/SessionManager.cs') diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs index ac69b0dc5..6bb6edf7a 100644 --- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs +++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs @@ -290,6 +290,7 @@ namespace MediaBrowser.Server.Implementations.Session var data = _userDataRepository.GetUserData(user.Id, key); UpdatePlayState(info.Item, data, info.PositionTicks.Value); + await _userDataRepository.SaveUserData(user.Id, key, data, UserDataSaveReason.PlaybackProgress, CancellationToken.None).ConfigureAwait(false); } @@ -501,7 +502,62 @@ namespace MediaBrowser.Server.Implementations.Session return session.SessionController.SendPlaystateCommand(command, cancellationToken); } - public Task SendRestartRequiredMessage(CancellationToken cancellationToken) + /// + /// Sends the restart required message. + /// + /// The cancellation token. + /// Task. + public Task SendRestartRequiredNotification(CancellationToken cancellationToken) + { + var sessions = Sessions.Where(i => i.IsActive && i.SessionController != null).ToList(); + + var tasks = sessions.Select(session => Task.Run(async () => + { + try + { + await session.SessionController.SendRestartRequiredNotification(cancellationToken).ConfigureAwait(false); + } + catch (Exception ex) + { + _logger.ErrorException("Error in SendRestartRequiredNotification.", ex); + } + + })); + + return Task.WhenAll(tasks); + } + + /// + /// Sends the server shutdown notification. + /// + /// The cancellation token. + /// Task. + public Task SendServerShutdownNotification(CancellationToken cancellationToken) + { + var sessions = Sessions.Where(i => i.IsActive && i.SessionController != null).ToList(); + + var tasks = sessions.Select(session => Task.Run(async () => + { + try + { + await session.SessionController.SendServerShutdownNotification(cancellationToken).ConfigureAwait(false); + } + catch (Exception ex) + { + _logger.ErrorException("Error in SendServerShutdownNotification.", ex); + } + + })); + + return Task.WhenAll(tasks); + } + + /// + /// Sends the server restart notification. + /// + /// The cancellation token. + /// Task. + public Task SendServerRestartNotification(CancellationToken cancellationToken) { var sessions = Sessions.Where(i => i.IsActive && i.SessionController != null).ToList(); @@ -509,11 +565,11 @@ namespace MediaBrowser.Server.Implementations.Session { try { - await session.SessionController.SendRestartRequiredMessage(cancellationToken).ConfigureAwait(false); + await session.SessionController.SendServerRestartNotification(cancellationToken).ConfigureAwait(false); } catch (Exception ex) { - _logger.ErrorException("Error in SendRestartRequiredMessage.", ex); + _logger.ErrorException("Error in SendServerRestartNotification.", ex); } })); -- cgit v1.2.3