aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/connection.js
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2014-12-30 21:51:07 +1300
committerAldo Cortesi <aldo@nullcube.com>2014-12-30 21:51:07 +1300
commitbc8687deb5f0f9273fc771e79b070f3b49e39fed (patch)
tree07e67eb7c9f732c0419e57b337c31d2372d12cff /web/src/js/connection.js
parentd2c7411f065435e2b2b62a70447cb01895fe69d1 (diff)
downloadmitmproxy-bc8687deb5f0f9273fc771e79b070f3b49e39fed.tar.gz
mitmproxy-bc8687deb5f0f9273fc771e79b070f3b49e39fed.tar.bz2
mitmproxy-bc8687deb5f0f9273fc771e79b070f3b49e39fed.zip
Basic conversion: browserified web app now works.
Diffstat (limited to 'web/src/js/connection.js')
-rw-r--r--web/src/js/connection.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/web/src/js/connection.js b/web/src/js/connection.js
index 6ca353b3..85514c3c 100644
--- a/web/src/js/connection.js
+++ b/web/src/js/connection.js
@@ -1,24 +1,28 @@
-function Connection(url) {
+var actions = require("./actions.js");
+
+function Connection(url) {
if (url[0] === "/") {
url = location.origin.replace("http", "ws") + url;
}
var ws = new WebSocket(url);
ws.onopen = function () {
- ConnectionActions.open();
+ actions.ConnectionActions.open();
};
ws.onmessage = function (message) {
var m = JSON.parse(message.data);
AppDispatcher.dispatchServerAction(m);
};
ws.onerror = function () {
- ConnectionActions.error();
+ actions.ConnectionActions.error();
EventLogActions.add_event("WebSocket connection error.");
};
ws.onclose = function () {
- ConnectionActions.close();
+ actions.ConnectionActions.close();
EventLogActions.add_event("WebSocket connection closed.");
};
return ws;
-} \ No newline at end of file
+}
+
+module.exports = Connection; \ No newline at end of file