Computer scienceBackendNode.jsClient-server interaction

Websocket server

Websocket broadcasting

Report a typo

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.

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