// client.js
document.forms[0].onsubmit = function() {
var input = document.getElementById('message');
ws.send(input.value);
input.value = '';
// server
(..)
wss.on("connection", function(ws) {
ws.on("message", function(message) {
if (message === 'exit') {
ws.close();
} else {
ws.clients.forEach(function(client) {
client.send(message);
});
}
});
ws.send("Welcome to the chat");
});