aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/Session/SessionManager.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2014-10-13 16:14:53 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2014-10-13 16:14:53 -0400
commitab3c26c5647a56e95d0f5229f07b1a1b45812ff8 (patch)
treebbcaf5db256364f19cdb4f7c18eb82171dc4183b /MediaBrowser.Server.Implementations/Session/SessionManager.cs
parent8a15ee6ab4149cf59f8ff2724e3e415d34557da1 (diff)
update connect
Diffstat (limited to 'MediaBrowser.Server.Implementations/Session/SessionManager.cs')
-rw-r--r--MediaBrowser.Server.Implementations/Session/SessionManager.cs24
1 files changed, 23 insertions, 1 deletions
diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs
index c16044bd3..21467ccda 100644
--- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs
+++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs
@@ -14,6 +14,7 @@ using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Controller.Security;
using MediaBrowser.Controller.Session;
+using MediaBrowser.Model.Devices;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Events;
using MediaBrowser.Model.Library;
@@ -129,6 +130,19 @@ namespace MediaBrowser.Server.Implementations.Session
_httpClient = httpClient;
_authRepo = authRepo;
_deviceManager = deviceManager;
+
+ _deviceManager.DeviceOptionsUpdated += _deviceManager_DeviceOptionsUpdated;
+ }
+
+ void _deviceManager_DeviceOptionsUpdated(object sender, GenericEventArgs<DeviceInfo> e)
+ {
+ foreach (var session in Sessions)
+ {
+ if (string.Equals(session.DeviceId, e.Argument.Id))
+ {
+ session.DeviceName = e.Argument.Name;
+ }
+ }
}
/// <summary>
@@ -397,6 +411,7 @@ namespace MediaBrowser.Server.Implementations.Session
try
{
SessionInfo connection;
+ DeviceInfo device = null;
if (!_activeConnections.TryGetValue(key, out connection))
{
@@ -421,10 +436,17 @@ namespace MediaBrowser.Server.Implementations.Session
if (!string.IsNullOrEmpty(deviceId))
{
var userIdString = userId.HasValue ? userId.Value.ToString("N") : null;
- await _deviceManager.RegisterDevice(deviceId, deviceName, clientType, userIdString).ConfigureAwait(false);
+ device = await _deviceManager.RegisterDevice(deviceId, deviceName, clientType, userIdString).ConfigureAwait(false);
}
}
+ device = device ?? _deviceManager.GetDevice(deviceId);
+
+ if (!string.IsNullOrEmpty(device.CustomName))
+ {
+ deviceName = device.CustomName;
+ }
+
connection.DeviceName = deviceName;
connection.UserId = userId;
connection.UserName = username;