theturtle32 / WebSocket-Node

A WebSocket Implementation for Node.JS (Draft -08 through the final RFC 6455)
Apache License 2.0
3.75k stars 604 forks source link

broadcast #439

Closed hokage4 closed 1 year ago

hokage4 commented 1 year ago

Hi, I want to send the broadcast to all clients connected to WebSocket

this code just send to the sender client I need all connected see the message

` var connection = request.accept('echo-protocol', request.origin); console.log((new Date()) + ' Connection accepted.'); connection.on('message', function(message) { if (message.type === 'utf8') {

        console.log('Received Message: ' + message.utf8Data);

     //   connection.sendUTF(" from server "+message.utf8Data);

     connection.sendUTF(" from server "+message.utf8Data);

    }
    else if (message.type === 'binary') {
        console.log('Received Binary Message of ' + message.binaryData.length + ' bytes');
        connection.sendBytes(message.binaryData);
    }`