From 751febc1de65c9f2811deca66d093503968dd514 Mon Sep 17 00:00:00 2001 From: softworkz Date: Fri, 19 Aug 2016 03:00:04 +0200 Subject: Auto-Organize: Async operation and instant feedback UI (reworked) This commit includes changes to enable and stabilize asyncronous operation in the auto-organize area. Here are the key points: - The auto-organize correction dialog is now closed (almost) instantly. This means that the user does not have to wait until the file copy/move operation is completed in order to continue. (even with local HDs the copy/move process can take several minutes or even much longer with network destination). - This commit also implements locking of files to be organized in order to prevent parallel processing of the same item. In effect, there can be 2 or more manual organization operations active even while the normal auto-organization task is running without causing any problems - The items that are currently being processed are indicated as such in the log with an orange color and a spinner graphic - The client display is refreshed through websocket messages - A side effect of this is that other clients showing the auto-organize log at the same time are always up-to-date as well --- .../Session/SessionManager.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (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 f495e557a..9d07f2169 100644 --- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs +++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs @@ -1869,6 +1869,27 @@ namespace MediaBrowser.Server.Implementations.Session return GetSessionByAuthenticationToken(info, deviceId, remoteEndpoint, null); } + public Task SendMessageToAdminSessions(string name, T data, CancellationToken cancellationToken) + { + // TODO: How to identify admin sessions? + var sessions = Sessions.Where(i => i.IsActive && i.SessionController != null).ToList(); + + var tasks = sessions.Select(session => Task.Run(async () => + { + try + { + await session.SessionController.SendMessage(name, data, cancellationToken).ConfigureAwait(false); + } + catch (Exception ex) + { + _logger.ErrorException("Error sending message", ex); + } + + }, cancellationToken)); + + return Task.WhenAll(tasks); + } + public Task SendMessageToUserSessions(string userId, string name, T data, CancellationToken cancellationToken) { -- cgit v1.2.3