aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/Session/SessionManager.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2013-10-07 23:06:12 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2013-10-07 23:06:12 -0400
commit9663252d10224a41bb35da006c8bd0248b98c169 (patch)
treeacbe4c273b66f9ad07ad57303cf600e140572f1f /MediaBrowser.Server.Implementations/Session/SessionManager.cs
parenta90908f0f72cfc27528e4df6516f9cca8897c818 (diff)
remove mutex from mono startup
Diffstat (limited to 'MediaBrowser.Server.Implementations/Session/SessionManager.cs')
-rw-r--r--MediaBrowser.Server.Implementations/Session/SessionManager.cs38
1 files changed, 13 insertions, 25 deletions
diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs
index d3b6bc59f..9fb9010e5 100644
--- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs
+++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs
@@ -44,13 +44,11 @@ namespace MediaBrowser.Server.Implementations.Session
/// <value>The configuration manager.</value>
private readonly IServerConfigurationManager _configurationManager;
- private object _sessionLock = new object();
-
/// <summary>
/// The _active connections
/// </summary>
- private readonly Dictionary<string, SessionInfo> _activeConnections =
- new Dictionary<string, SessionInfo>(StringComparer.OrdinalIgnoreCase);
+ private readonly ConcurrentDictionary<string, SessionInfo> _activeConnections =
+ new ConcurrentDictionary<string, SessionInfo>(StringComparer.OrdinalIgnoreCase);
/// <summary>
/// Occurs when [playback start].
@@ -86,7 +84,7 @@ namespace MediaBrowser.Server.Implementations.Session
/// <value>All connections.</value>
public IEnumerable<SessionInfo> Sessions
{
- get { return _activeConnections.Values.ToList().OrderByDescending(c => c.LastActivityDate); }
+ get { return _activeConnections.Values.OrderByDescending(c => c.LastActivityDate).ToList(); }
}
/// <summary>
@@ -195,28 +193,18 @@ namespace MediaBrowser.Server.Implementations.Session
{
var key = clientType + deviceId + appVersion;
- lock (_sessionLock)
+ var connection = _activeConnections.GetOrAdd(key, keyName => new SessionInfo
{
- SessionInfo connection;
+ Client = clientType,
+ DeviceId = deviceId,
+ ApplicationVersion = appVersion,
+ Id = Guid.NewGuid()
+ });
- if (!_activeConnections.TryGetValue(key, out connection))
- {
- connection = new SessionInfo
- {
- Client = clientType,
- DeviceId = deviceId,
- ApplicationVersion = appVersion,
- Id = Guid.NewGuid()
- };
-
- _activeConnections[key] = connection;
- }
+ connection.DeviceName = deviceName;
+ connection.User = user;
- connection.DeviceName = deviceName;
- connection.User = user;
-
- return connection;
- }
+ return connection;
}
/// <summary>
@@ -589,4 +577,4 @@ namespace MediaBrowser.Server.Implementations.Session
return Task.WhenAll(tasks);
}
}
-}
+} \ No newline at end of file