diff --git a/src/rust/lqosd/src/node_manager/js_build/src/pubsub/direct_channels.js b/src/rust/lqosd/src/node_manager/js_build/src/pubsub/direct_channels.js index 908f443b..707f38ae 100644 --- a/src/rust/lqosd/src/node_manager/js_build/src/pubsub/direct_channels.js +++ b/src/rust/lqosd/src/node_manager/js_build/src/pubsub/direct_channels.js @@ -1,8 +1,10 @@ +import {ws_proto} from './ws.js'; + export class DirectChannel { constructor(subObject, handler) { this.ws = null; this.handler = handler; - this.ws = new WebSocket('ws://' + window.location.host + '/websocket/private_ws'); + this.ws = new WebSocket(ws_proto() + window.location.host + '/websocket/private_ws'); this.ws.onopen = () => { this.ws.send(JSON.stringify(subObject)); } diff --git a/src/rust/lqosd/src/node_manager/js_build/src/pubsub/ws.js b/src/rust/lqosd/src/node_manager/js_build/src/pubsub/ws.js index 5af1f2ee..c780aa6a 100644 --- a/src/rust/lqosd/src/node_manager/js_build/src/pubsub/ws.js +++ b/src/rust/lqosd/src/node_manager/js_build/src/pubsub/ws.js @@ -1,12 +1,20 @@ // Setup any WS feeds for this page let ws = null; +export function ws_proto() { + if (window.location.protocl === 'https') { + return "wss://"; + } else { + return "ws://"; + } +} + export function subscribeWS(channels, handler) { if (ws) { ws.close(); } - ws = new WebSocket('ws://' + window.location.host + '/websocket/ws'); + ws = new WebSocket(ws_proto() + window.location.host + '/websocket/ws'); ws.onopen = () => { for (let i=0; i