From be5bdd9b6e7f9546d80a7d4a12a0fdb863e7a9df Mon Sep 17 00:00:00 2001 From: Rikkert Koppes Date: Sat, 16 Jul 2016 15:52:10 +0200 Subject: [PATCH] allow double config for ws and wss seperately --- config.js | 5 +++-- js/main.js | 14 +++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/config.js b/config.js index a0654e5..ce17d22 100644 --- a/config.js +++ b/config.js @@ -1,7 +1,8 @@ displaySystem.config({ //websocket host to listen to - // wsHost: "localhost:13900/", - wsHost: "localhost.daplie.com:13900/", + wsHost: "localhost:13900/", + //host to listen to in case of a secure connection + wssHost: "localhost.daplie.com:13900/", //specify the node that is being subscribed to when using mserver mserverNode: "default", //modules, order determines z stacking diff --git a/js/main.js b/js/main.js index 39e082a..67b1f99 100644 --- a/js/main.js +++ b/js/main.js @@ -52,13 +52,17 @@ var displaySystem = (function() { var pendingConnection; function initWebsocket(config) { - var ws; - if (config.wsHost) { + var ws, host; + if (config.wsHost || config.wssHost) { if (pendingConnection) { clearTimeout(pendingConnection); } - var protocol = (window.location.protocol === 'https:')?'wss://':'ws://'; - ws = new WebSocket(protocol + config.wsHost); + if (window.location.protocol === 'https:') { + host = 'wss://'+config.wssHost; + } else { + host = 'ws://'+config.wsHost; + } + ws = new WebSocket(host); ws.onopen = function() { if (config.mserverNode) { @@ -133,7 +137,7 @@ var displaySystem = (function() { } function sendMessage(def,action,data) { - if (config.wsHost) { + if (config.wsHost || config.wssHost) { ws.send(JSON.stringify({ type: "publish", node: config.mserverNode,