Open 6pm opened 7 years ago
You can get the list of all clients per the API docs, then send a message to each one:
ws.getWss().clients.forEach(client => client.send(payload));
what if I have millions connected user. Will it work efficiently?
@abhishek11210646 I wouldn't think so, it's O(n)
您可以根据API文档获取所有客户的列表,然后向每个客户发送一条消息:
ws.getWss().clients.forEach(client => client.send(payload));
How to broadcast a message to some specific users
I answered this a bit ago. https://github.com/HenningM/express-ws/issues/140#issuecomment-900628888
How to send broadcast message for all users? I used before
connection.sendUTF(json)
with pure node server. Thank you for answer.