diff options
author | Alexis Hovorka <[email protected]> | 2021-07-12 16:00:04 -0600 |
---|---|---|
committer | Alexis Hovorka <[email protected]> | 2021-07-12 16:00:04 -0600 |
commit | 6205eb63c0047629f9f146c56fc8760c9bc2e65b (patch) | |
tree | ea31d7af45482a8228911b49edcb95fc91ae34c1 /public/main.js |
Initial commit
Diffstat (limited to 'public/main.js')
-rw-r--r-- | public/main.js | 16 |
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); +}); + +}); |