Broadcast
verb
say it: “BRAWD-kast” /ˈbrɔdˌkæst/
To send one message to every connected listener at the same time.
What does it mean to broadcast a message?
To broadcast is to send the same message to every connected client at once, such as a new score to everyone watching a match. The server loops over its open connections and sends to each one.
function broadcast(message) {
for (const client of wss.clients) {
if (client.readyState === WebSocket.OPEN) client.send(message);
}
}
broadcast(JSON.stringify({ home: 2, away: 1 }));
In a sentence
- “The class app can broadcast "Class starts in 5 minutes" to every student who has it open.”
- “When a goal is scored, the server sends a broadcast to all 400 fans.”
Level: Apprentice · More Web Development terms at this level
Updated