mirror of
https://github.com/tokio-rs/axum.git
synced 2024-12-28 23:38:20 +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 = "";
|
|
});
|