Do not hardcode websocket host

This commit is contained in:
Marvin Scholz 2017-05-13 02:14:20 +02:00
parent 7aed274e63
commit 0b65c79a89

View file

@ -95,7 +95,11 @@
var queue = [];
var archive = [];
var exampleSocket = new WebSocket("ws://Marvins-MacBook-Pro.local:8000/ws");
// Construct websocket url
var loc = window.location;
var ws_url = ((loc.protocol === "https:") ? "wss://" : "ws://") + loc.host + "/ws";
var exampleSocket = new WebSocket(ws_url);
exampleSocket.onopen = function (event) {
console.log("WS: Connection open");
};