]> git.zarvox.org Git - imoo.git/commitdiff
Make websocket bind to the host in the specified URI
authorDrew Fisher <drew.m.fisher@gmail.com>
Mon, 19 May 2014 01:25:44 +0000 (21:25 -0400)
committerDrew Fisher <drew.m.fisher@gmail.com>
Mon, 19 May 2014 01:25:44 +0000 (21:25 -0400)
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...

reactornado/main.js

index 3c2147a7b55a8c9ddbd843f6afc52337534a69e3..8353f2de89edd3e7fda972783c8bc521e7c73af0 100644 (file)
@@ -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);