More progress towards working websockets stuff. Add mime-types.scm to contrib.
[mudsync.git] / data / web-static / js / mudsync.js
diff --git a/data/web-static/js/mudsync.js b/data/web-static/js/mudsync.js
new file mode 100644 (file)
index 0000000..f2edef9
--- /dev/null
@@ -0,0 +1,23 @@
+function displayMessage(data) {
+    console.log("received message");
+    console.log(data);
+}
+
+function installWebsocket() {
+    // TODO: Don't hardcode the websocket path; pull it from the DOM
+    var ws = new WebSocket("ws://127.0.0.1:8888");
+    ws.onmessage = function(evt) {
+        displayMessage(evt.data);
+    };
+    ws.onopen = function() {
+        console.log("connected");
+        ws.send("Hello, there!");
+    };
+    ws.onclose = function () {
+        console.log("closed websocket");
+    };
+}
+
+window.onload = function () {
+    installWebsocket();
+}