diff options
author | Maximilian Hils <git@maximilianhils.com> | 2014-09-15 18:08:26 +0200 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2014-09-15 18:08:26 +0200 |
commit | cbf18320cdbd05197f232da69b3c9a5391735156 (patch) | |
tree | 63b9cf8fd6a8e8fb5be6b2d5a655acf3d33b6229 /web/src/js/Connection.es6.js | |
parent | 9f8d2eea64d4611c1e2f7e7043fe6d3ef9a6aa40 (diff) | |
download | mitmproxy-cbf18320cdbd05197f232da69b3c9a5391735156.tar.gz mitmproxy-cbf18320cdbd05197f232da69b3c9a5391735156.tar.bz2 mitmproxy-cbf18320cdbd05197f232da69b3c9a5391735156.zip |
client-side structure
Diffstat (limited to 'web/src/js/Connection.es6.js')
-rw-r--r-- | web/src/js/Connection.es6.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/web/src/js/Connection.es6.js b/web/src/js/Connection.es6.js new file mode 100644 index 00000000..9daa82e2 --- /dev/null +++ b/web/src/js/Connection.es6.js @@ -0,0 +1,33 @@ +class Connection { + constructor(root){ + if(!root){ + root = location.origin + "/api/v1"; + } + this.root = root; + this.openWebSocketConnection(); + } + + openWebSocketConnection(){ + 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); + } + + onopen(open){ + console.log("onopen", this, arguments); + } + onmessage(message){ + console.log("onmessage", this, arguments); + } + onerror(error){ + console.log("onerror", this, arguments); + } + onclose(close){ + console.log("onclose", this, arguments); + } + +} |