Fill in the blanks in the code snippet to enable WebSocket broadcasting to every other connected client, excluding the client that sent the original message.
Websocket server
Websocket broadcasting
Report a typo
Fill in the gaps with the relevant elements
import { WebSocketServer } from 'ws';
const wss = new WebSocketServer({ port: 8080 });
wss.on('connection', function connection(ws) {
ws.on('error', console.error);
ws.on('message', function message(data, isBinary) {
wss.clients.forEach(function each(client) {
if (client !== && client. === WebSocket.OPEN) {
client.send(, { : isBinary });
}
});
});
});Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.