From ab3c26c5647a56e95d0f5229f07b1a1b45812ff8 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 13 Oct 2014 16:14:53 -0400 Subject: update connect --- .../Session/SessionManager.cs | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'MediaBrowser.Server.Implementations/Session') diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs index c16044bd36..21467ccda9 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 e) + { + foreach (var session in Sessions) + { + if (string.Equals(session.DeviceId, e.Argument.Id)) + { + session.DeviceName = e.Argument.Name; + } + } } /// @@ -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; -- cgit v1.2.3