From 5fd8da389b6a219670d33994474c71290889c297 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 8 Mar 2015 15:48:30 -0400 Subject: [PATCH] connect to socket with access token --- .../thirdparty/apiclient/mediabrowser.apiclient.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/dashboard-ui/thirdparty/apiclient/mediabrowser.apiclient.js b/dashboard-ui/thirdparty/apiclient/mediabrowser.apiclient.js index b922a48d94..6e640de2ef 100644 --- a/dashboard-ui/thirdparty/apiclient/mediabrowser.apiclient.js +++ b/dashboard-ui/thirdparty/apiclient/mediabrowser.apiclient.js @@ -337,7 +337,12 @@ self.openWebSocket = function () { + if (!accessToken) { + throw new Error("Cannot open web socket without access token."); + } + var url = serverAddress.replace('http', 'ws'); + url += "?api_key=" + accessToken; webSocket = new WebSocket(url); @@ -351,12 +356,8 @@ logger.log('web socket connection opened'); setTimeout(function () { - - self.sendWebSocketMessage("Identity", clientName + "|" + deviceId + "|" + applicationVersion + "|" + deviceName); - Events.trigger(self, 'websocketopen'); - - }, 500); + }, 0); }; webSocket.onerror = function () { setTimeout(function () {