From 7385f6a830bd76adcb115bbfb838e991680d62c5 Mon Sep 17 00:00:00 2001 From: TheNain38 Date: Sat, 16 Jul 2016 12:49:33 +0200 Subject: [PATCH] Make it work on whatever domain it is on --- websocket-chat/src/webroot/js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-chat/src/webroot/js/main.js b/websocket-chat/src/webroot/js/main.js index 9e8fd54..d97bb9c 100644 --- a/websocket-chat/src/webroot/js/main.js +++ b/websocket-chat/src/webroot/js/main.js @@ -4,7 +4,7 @@ define( "MessageList" ], function(MessageList) { - var ws = new WebSocket("ws://localhost:8080/entry"); + var ws = new WebSocket("ws" + (window.location.protocol==="https:"?"s":"") + "://"+ window.location.hostname + (window.location.port?":"+window.location.port:"") + "/entry"); var list = new MessageList(ws); ko.applyBindings(list); }