summaryrefslogtreecommitdiff
path: root/public/main.js
diff options
context:
space:
mode:
authorAlexis Hovorka <[email protected]>2021-07-12 16:00:04 -0600
committerAlexis Hovorka <[email protected]>2021-07-12 16:00:04 -0600
commit6205eb63c0047629f9f146c56fc8760c9bc2e65b (patch)
treeea31d7af45482a8228911b49edcb95fc91ae34c1 /public/main.js
Initial commit
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);
+});
+
+});