diff options
author | Maximilian Hils <git@maximilianhils.com> | 2014-09-16 00:05:06 +0200 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2014-09-16 00:05:06 +0200 |
commit | acdd182754625fabcfc2c6ed4bdad8a63bce8ad6 (patch) | |
tree | bd48b8c269790d31913a13ecac8969c9d6413f0e /web/src/js/Connection.es6.js | |
parent | 1d9b1f79a11feb57043be1d9d656f4c1638d3357 (diff) | |
download | mitmproxy-acdd182754625fabcfc2c6ed4bdad8a63bce8ad6.tar.gz mitmproxy-acdd182754625fabcfc2c6ed4bdad8a63bce8ad6.tar.bz2 mitmproxy-acdd182754625fabcfc2c6ed4bdad8a63bce8ad6.zip |
web: implement EventLogStore
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 |