diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2014-09-16 16:26:16 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2014-09-16 16:27:09 +1200 |
commit | 6efe1aa6a92ce7f9f264903e9d27fb5cf6c32bfe (patch) | |
tree | e654b27eeb7a44c61c0e1a43850966735aefb3cd /web/src/js/connection.js | |
parent | 6bac1540bd9383c4e6e0510d9b75db34346187ed (diff) | |
download | mitmproxy-6efe1aa6a92ce7f9f264903e9d27fb5cf6c32bfe.tar.gz mitmproxy-6efe1aa6a92ce7f9f264903e9d27fb5cf6c32bfe.tar.bz2 mitmproxy-6efe1aa6a92ce7f9f264903e9d27fb5cf6c32bfe.zip |
We're not ready for ES6
Lets re-evaluate in June next year when it's actually released
Diffstat (limited to 'web/src/js/connection.js')
-rw-r--r-- | web/src/js/connection.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/web/src/js/connection.js b/web/src/js/connection.js new file mode 100644 index 00000000..1f2daeef --- /dev/null +++ b/web/src/js/connection.js @@ -0,0 +1,33 @@ +function _Connection(root) {"use strict"; + if (!root) { + root = location.origin + "/api/v1"; + } + this.root = root; + } + _Connection.prototype.init=function() {"use strict"; + this.openWebSocketConnection(); + }; + _Connection.prototype.openWebSocketConnection=function() {"use strict"; + this.ws = new WebSocket(this.root.replace("http", "ws") + "/ws"); + var ws = this.ws; + + ws.onopen = this.onopen.bind(this); + ws.onmessage = this.onmessage.bind(this); + ws.onerror = this.onerror.bind(this); + ws.onclose = this.onclose.bind(this); + }; + _Connection.prototype.onopen=function(open) {"use strict"; + console.log("onopen", this, arguments); + }; + _Connection.prototype.onmessage=function(message) {"use strict"; + //AppDispatcher.dispatchServerAction(...); + console.log("onmessage", this, arguments); + }; + _Connection.prototype.onerror=function(error) {"use strict"; + console.log("onerror", this, arguments); + }; + _Connection.prototype.onclose=function(close) {"use strict"; + console.log("onclose", this, arguments); + }; + +var Connection = new _Connection(); |