From 44f33fdb555aa9be3d710f7e81b995730ae836be Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 10 May 2013 08:18:07 -0400 Subject: progress on remote control --- .../Session/SessionManager.cs | 66 +++++++++++----------- 1 file changed, 33 insertions(+), 33 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 99407e349..2f9c7e389 100644 --- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs +++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs @@ -1,14 +1,12 @@ using MediaBrowser.Common.Events; using MediaBrowser.Common.Net; using MediaBrowser.Controller.Configuration; -using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Persistence; using MediaBrowser.Controller.Session; using MediaBrowser.Model.Logging; -using MediaBrowser.Model.Session; using System; using System.Collections.Concurrent; using System.Collections.Generic; @@ -18,10 +16,19 @@ using System.Threading.Tasks; namespace MediaBrowser.Server.Implementations.Session { + /// + /// Class SessionManager + /// public class SessionManager : ISessionManager { + /// + /// The _user data repository + /// private readonly IUserDataRepository _userDataRepository; + /// + /// The _user repository + /// private readonly IUserRepository _userRepository; /// @@ -54,6 +61,13 @@ namespace MediaBrowser.Server.Implementations.Session /// public event EventHandler PlaybackStopped; + /// + /// Initializes a new instance of the class. + /// + /// The user data repository. + /// The configuration manager. + /// The logger. + /// The user repository. public SessionManager(IUserDataRepository userDataRepository, IServerConfigurationManager configurationManager, ILogger logger, IUserRepository userRepository) { _userDataRepository = userDataRepository; @@ -66,20 +80,14 @@ namespace MediaBrowser.Server.Implementations.Session /// Gets all connections. /// /// All connections. - public IEnumerable AllConnections + public IEnumerable Sessions { - get { return _activeConnections.Values.OrderByDescending(c => c.LastActivityDate); } + get { return _activeConnections.Values.OrderByDescending(c => c.LastActivityDate).ToList(); } } /// - /// Gets the active connections. + /// The _true task result /// - /// The active connections. - public IEnumerable RecentConnections - { - get { return AllConnections.Where(c => (DateTime.UtcNow - c.LastActivityDate).TotalMinutes <= 5); } - } - private readonly Task _trueTaskResult = Task.FromResult(true); /// @@ -124,11 +132,13 @@ namespace MediaBrowser.Server.Implementations.Session /// The device id. /// Name of the device. /// The item. + /// if set to true [is paused]. /// The current position ticks. - private void UpdateNowPlayingItemId(User user, string clientType, string deviceId, string deviceName, BaseItem item, long? currentPositionTicks = null) + private void UpdateNowPlayingItemId(User user, string clientType, string deviceId, string deviceName, BaseItem item, bool isPaused, long? currentPositionTicks = null) { var conn = GetConnection(clientType, deviceId, deviceName, user); + conn.IsPaused = isPaused; conn.NowPlayingPositionTicks = currentPositionTicks; conn.NowPlayingItem = item; conn.LastActivityDate = DateTime.UtcNow; @@ -150,6 +160,7 @@ namespace MediaBrowser.Server.Implementations.Session { conn.NowPlayingItem = null; conn.NowPlayingPositionTicks = null; + conn.IsPaused = null; } } @@ -187,7 +198,8 @@ namespace MediaBrowser.Server.Implementations.Session /// Type of the client. /// The device id. /// Name of the device. - /// + /// + /// public void OnPlaybackStart(User user, BaseItem item, string clientType, string deviceId, string deviceName) { if (user == null) @@ -199,7 +211,7 @@ namespace MediaBrowser.Server.Implementations.Session throw new ArgumentNullException(); } - UpdateNowPlayingItemId(user, clientType, deviceId, deviceName, item); + UpdateNowPlayingItemId(user, clientType, deviceId, deviceName, item, false); // Nothing to save here // Fire events to inform plugins @@ -216,12 +228,14 @@ namespace MediaBrowser.Server.Implementations.Session /// The user. /// The item. /// The position ticks. + /// if set to true [is paused]. /// Type of the client. /// The device id. /// Name of the device. /// Task. - /// - public async Task OnPlaybackProgress(User user, BaseItem item, long? positionTicks, string clientType, string deviceId, string deviceName) + /// + /// + public async Task OnPlaybackProgress(User user, BaseItem item, long? positionTicks, bool isPaused, string clientType, string deviceId, string deviceName) { if (user == null) { @@ -232,7 +246,7 @@ namespace MediaBrowser.Server.Implementations.Session throw new ArgumentNullException(); } - UpdateNowPlayingItemId(user, clientType, deviceId, deviceName, item, positionTicks); + UpdateNowPlayingItemId(user, clientType, deviceId, deviceName, item, isPaused, positionTicks); var key = item.GetUserDataKey(); @@ -262,7 +276,8 @@ namespace MediaBrowser.Server.Implementations.Session /// The device id. /// Name of the device. /// Task. - /// + /// + /// public async Task OnPlaybackStopped(User user, BaseItem item, long? positionTicks, string clientType, string deviceId, string deviceName) { if (user == null) @@ -355,20 +370,5 @@ namespace MediaBrowser.Server.Implementations.Session data.LastPlayedDate = DateTime.UtcNow; } } - - /// - /// Identifies the web socket. - /// - /// The session id. - /// The web socket. - public void IdentifyWebSocket(Guid sessionId, IWebSocketConnection webSocket) - { - var session = AllConnections.FirstOrDefault(i => i.Id == sessionId); - - if (session != null) - { - session.WebSocket = webSocket; - } - } } } -- cgit v1.2.3