mirror of
https://github.com/tokio-rs/axum.git
synced 2024-11-21 22:56:46 +01:00
11 lines
390 B
JavaScript
11 lines
390 B
JavaScript
const socket = new WebSocket('wss://localhost:3000/ws');
|
|
|
|
socket.addEventListener('message', e => {
|
|
document.getElementById("messages").append(e.data, document.createElement("br"));
|
|
});
|
|
|
|
const form = document.querySelector("form");
|
|
form.addEventListener("submit", () => {
|
|
socket.send(form.elements.namedItem("content").value);
|
|
form.elements.namedItem("content").value = "";
|
|
});
|