From f988539e13e9f0a4bc206d2b6803520a35b7228e Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 16 Mar 2015 12:47:14 -0400 Subject: update session listener --- MediaBrowser.Server.Implementations/Session/SessionManager.cs | 9 ++------- .../Session/SessionWebSocketListener.cs | 8 +++++++- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Session') diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs index 76e97ff48..8a21ed6bd 100644 --- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs +++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs @@ -1687,16 +1687,11 @@ namespace MediaBrowser.Server.Implementations.Session AccessToken = token }); - if (result.Items.Length == 0) - { - return null; - } - - var info = result.Items[0]; + var info = result.Items.FirstOrDefault(); if (info == null) { - return null; + return Task.FromResult(null); } return GetSessionByAuthenticationToken(info, deviceId, remoteEndpoint, null); diff --git a/MediaBrowser.Server.Implementations/Session/SessionWebSocketListener.cs b/MediaBrowser.Server.Implementations/Session/SessionWebSocketListener.cs index dda4c2b90..b8cab0c19 100644 --- a/MediaBrowser.Server.Implementations/Session/SessionWebSocketListener.cs +++ b/MediaBrowser.Server.Implementations/Session/SessionWebSocketListener.cs @@ -85,7 +85,8 @@ namespace MediaBrowser.Server.Implementations.Session async void _httpServer_WebSocketConnecting(object sender, WebSocketConnectingEventArgs e) { - if (e.QueryString.AllKeys.Contains("api_key", StringComparer.OrdinalIgnoreCase)) + var token = e.QueryString["api_key"]; + if (!string.IsNullOrWhiteSpace(token)) { var session = await GetSession(e.QueryString, e.Endpoint).ConfigureAwait(false); @@ -98,6 +99,11 @@ namespace MediaBrowser.Server.Implementations.Session private Task GetSession(NameValueCollection queryString, string remoteEndpoint) { + if (queryString == null) + { + throw new ArgumentNullException("queryString"); + } + var token = queryString["api_key"]; if (string.IsNullOrWhiteSpace(token)) { -- cgit v1.2.3