axum/examples/websockets/assets/script.js
David Pedersen 6c9651c14a
Move all examples to their own crates (#201)
This makes it much clearer which dependencies each example has.
2021-08-18 00:49:01 +02:00

9 lines
258 B
JavaScript

const socket = new WebSocket('ws://localhost:3000/ws');
socket.addEventListener('open', function (event) {
socket.send('Hello Server!');
});
socket.addEventListener('message', function (event) {
console.log('Message from server ', event.data);
});