From: Drew Fisher Date: Mon, 19 May 2014 01:25:44 +0000 (-0400) Subject: Make websocket bind to the host in the specified URI X-Git-Url: https://git.zarvox.org/shortlog/month?a=commitdiff_plain;h=812dca2df44f2540be19ab61290723153d677f13;p=imoo.git Make websocket bind to the host in the specified URI It's especially confusing to try to debug this if there's still a websocket server running at the place you're wrongly connecting to... --- diff --git a/reactornado/main.js b/reactornado/main.js index 3c2147a..8353f2d 100644 --- a/reactornado/main.js +++ b/reactornado/main.js @@ -5,7 +5,9 @@ window.conversations = {} // buid -> {proto, account, buddy, messages[], visible window.onload = function () { // Create websocket and attach to window - var ws = new WebSocket("ws://localhost:8889/ws"); + var scheme = (window.location.protocol === "https:") ? "wss:" : "ws:" ; + var ws_uri = scheme + "//" + window.location.host + "/ws"; + var ws = new WebSocket(ws_uri); ws.onmessage = function(evt) { //console.log("message received: " + evt.data);