mirror of
https://github.com/tokio-rs/axum.git
synced 2024-11-22 07:08:16 +01:00
12 lines
390 B
JavaScript
12 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 = "";
|
||
|
});
|