From 7437f8f209a9f4f91a0f335dd0c6cebaeb98de3a Mon Sep 17 00:00:00 2001 From: caroline-church Date: Tue, 13 Mar 2018 14:36:11 +0000 Subject: [PATCH] update support for wss (#122) Signed-off-by: Caroline Church --- .../app/views/dashboard/dashboard.controller.js | 2 +- .../client/app/directives/header/header.directive.js | 4 ++-- .../app/views/dashboard/dashboard.controller.js | 11 +++++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/vehicle-manufacture-manufacturing/client/app/views/dashboard/dashboard.controller.js b/packages/vehicle-manufacture-manufacturing/client/app/views/dashboard/dashboard.controller.js index c4b553e0..6f8748c6 100644 --- a/packages/vehicle-manufacture-manufacturing/client/app/views/dashboard/dashboard.controller.js +++ b/packages/vehicle-manufacture-manufacturing/client/app/views/dashboard/dashboard.controller.js @@ -105,7 +105,7 @@ angular.module('bc-manufacturer') } console.log(' Connecting to websocket', wsUri); var webSocketURL = wsUri; - let websocket = new WebSocket(webSocketURL); + var websocket = new WebSocket(webSocketURL); websocket.onopen = function () { console.log('Websocket is open'); } diff --git a/packages/vehicle-manufacture-vda/client/app/directives/header/header.directive.js b/packages/vehicle-manufacture-vda/client/app/directives/header/header.directive.js index 31157af0..26b98a00 100644 --- a/packages/vehicle-manufacture-vda/client/app/directives/header/header.directive.js +++ b/packages/vehicle-manufacture-vda/client/app/directives/header/header.directive.js @@ -37,8 +37,8 @@ angular.module('bc-vda') return route === location.path(); } - let destroyed = false; - let websocket; + var destroyed = false; + var websocket; function openWebSocket() { var wsUri = ''; diff --git a/packages/vehicle-manufacture-vda/client/app/views/dashboard/dashboard.controller.js b/packages/vehicle-manufacture-vda/client/app/views/dashboard/dashboard.controller.js index 361b63ec..dccebb0f 100644 --- a/packages/vehicle-manufacture-vda/client/app/views/dashboard/dashboard.controller.js +++ b/packages/vehicle-manufacture-vda/client/app/views/dashboard/dashboard.controller.js @@ -84,9 +84,16 @@ angular.module('bc-vda') // Websockets var destroyed = false; - let websocket; + var websocket; function openWebSocket() { - var webSocketURL = 'ws://' + location.host; + var wsUri = ''; + if (location.protocol === 'https:') { + wsUri = 'wss://' + location.host; + } else { + wsUri = 'ws://' + location.hostname + ':' + location.port; + } + console.log(' Connecting to websocket', wsUri); + var webSocketURL = wsUri; websocket = new WebSocket(webSocketURL); websocket.onopen = function () {