Skip to content
This repository has been archived by the owner on Jun 16, 2018. It is now read-only.

Commit

Permalink
allow double config for ws and wss seperately
Browse files Browse the repository at this point in the history
  • Loading branch information
rikkertkoppes committed Jul 16, 2016
1 parent 9bc459c commit be5bdd9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
5 changes: 3 additions & 2 deletions config.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 9 additions & 5 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit be5bdd9

Please sign in to comment.