summaryrefslogtreecommitdiff
path: root/public/main.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/main.js')
-rw-r--r--public/main.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/public/main.js b/public/main.js
new file mode 100644
index 0000000..8df390a
--- /dev/null
+++ b/public/main.js
@@ -0,0 +1,16 @@
+document.addEventListener("DOMContentLoaded", async () => { "use strict";
+
+const $ = s => document.querySelector(s);
+const secure = location.protocol === "https:";
+sock.init(`ws${secure?"s":""}://${location.host}/ws`);
+
+sock.on("hello", e => {
+ console.log("hello", e);
+ sock.send("world", {foo:"bar"});
+});
+
+sock.on("yay", e => {
+ console.log("yay", e);
+});
+
+});