diff options
Diffstat (limited to 'web/src/js/Connection.es6.js')
-rw-r--r-- | web/src/js/Connection.es6.js | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/web/src/js/Connection.es6.js b/web/src/js/Connection.es6.js index 9daa82e2..05d86c93 100644 --- a/web/src/js/Connection.es6.js +++ b/web/src/js/Connection.es6.js @@ -1,14 +1,17 @@ -class Connection { - constructor(root){ - if(!root){ +class _Connection { + constructor(root) { + if (!root) { root = location.origin + "/api/v1"; } this.root = root; + } + + init() { this.openWebSocketConnection(); } - openWebSocketConnection(){ - this.ws = new WebSocket(this.root.replace("http","ws") + "/ws"); + openWebSocketConnection() { + this.ws = new WebSocket(this.root.replace("http", "ws") + "/ws"); var ws = this.ws; ws.onopen = this.onopen.bind(this); @@ -17,17 +20,19 @@ class Connection { ws.onclose = this.onclose.bind(this); } - onopen(open){ + onopen(open) { console.log("onopen", this, arguments); } - onmessage(message){ + onmessage(message) { + //AppDispatcher.dispatchServerAction(...); console.log("onmessage", this, arguments); } - onerror(error){ + onerror(error) { console.log("onerror", this, arguments); } - onclose(close){ + onclose(close) { console.log("onclose", this, arguments); } } +var Connection = new _Connection();
\ No newline at end of file |