Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How to send broadcast message? #80

Open
6pm opened this issue Jul 31, 2017 · 5 comments
Open

[Question] How to send broadcast message? #80

6pm opened this issue Jul 31, 2017 · 5 comments

Comments

@6pm
Copy link

6pm commented Jul 31, 2017

How to send broadcast message for all users?
I used before connection.sendUTF(json) with pure node server.
Thank you for answer.

@textbook
Copy link

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));  

@abhishek11210646
Copy link

what if I have millions connected user. Will it work efficiently?

@textbook
Copy link

@abhishek11210646 I wouldn't think so, it's O(n)

@skingorz
Copy link

您可以根据API文档获取所有客户的列表,然后向每个客户发送一条消息:

ws.getWss().clients.forEach(client => client.send(payload));  

How to broadcast a message to some specific users

@Perodactyl
Copy link

I answered this a bit ago.
#140 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants