From a90908f0f72cfc27528e4df6516f9cca8897c818 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 7 Oct 2013 14:22:31 -0400 Subject: update service text in wizard --- .../Session/SessionManager.cs | 36 ++++++++++++++-------- 1 file changed, 24 insertions(+), 12 deletions(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs index 6bb6edf7a3..d3b6bc59f0 100644 --- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs +++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs @@ -44,11 +44,13 @@ namespace MediaBrowser.Server.Implementations.Session /// The configuration manager. private readonly IServerConfigurationManager _configurationManager; + private object _sessionLock = new object(); + /// /// The _active connections /// - private readonly ConcurrentDictionary _activeConnections = - new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); + private readonly Dictionary _activeConnections = + new Dictionary(StringComparer.OrdinalIgnoreCase); /// /// Occurs when [playback start]. @@ -84,7 +86,7 @@ namespace MediaBrowser.Server.Implementations.Session /// All connections. public IEnumerable Sessions { - get { return _activeConnections.Values.OrderByDescending(c => c.LastActivityDate).ToList(); } + get { return _activeConnections.Values.ToList().OrderByDescending(c => c.LastActivityDate); } } /// @@ -193,18 +195,28 @@ namespace MediaBrowser.Server.Implementations.Session { var key = clientType + deviceId + appVersion; - var connection = _activeConnections.GetOrAdd(key, keyName => new SessionInfo + lock (_sessionLock) { - Client = clientType, - DeviceId = deviceId, - ApplicationVersion = appVersion, - Id = Guid.NewGuid() - }); + SessionInfo connection; - connection.DeviceName = deviceName; - connection.User = user; + if (!_activeConnections.TryGetValue(key, out connection)) + { + connection = new SessionInfo + { + Client = clientType, + DeviceId = deviceId, + ApplicationVersion = appVersion, + Id = Guid.NewGuid() + }; + + _activeConnections[key] = connection; + } - return connection; + connection.DeviceName = deviceName; + connection.User = user; + + return connection; + } } /// -- cgit v1.2.3