script.js
This file
Path
examples/websockets/assets/script.js
25 lines · 656 bytes · JavaScript
Last changed by
Not known.
History of this fileTake it
The walk stopped after 200 commits: lines older than dcbcf5c point at it.
axum-extra: Make typed-routing feature enable routing feature (#3514)tottotobefore adoptiondcbcf5c
lines 1–25why, one step back1const socket = new WebSocket('ws://localhost:3000/ws');23socket.addEventListener('open', function (event) {4 socket.send('Hello Server!');5});67socket.addEventListener('message', function (event) {8 console.log('Message from server ', event.data);9});101112setTimeout(() => {13 const obj = { hello: "world" };14 const blob = new Blob([JSON.stringify(obj, null, 2)], {15 type: "application/json",16 });17 console.log("Sending blob over websocket");18 socket.send(blob);19}, 1000);2021setTimeout(() => {22 socket.send('About done here...');23 console.log("Sending close over websocket");24 socket.close(3000, "Crash and Burn!");25}, 3000);