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

Enable emitting to single client in managers with to=... #1375

Closed
rustworthy opened this issue Aug 17, 2024 · 2 comments
Closed

Enable emitting to single client in managers with to=... #1375

rustworthy opened this issue Aug 17, 2024 · 2 comments

Comments

@rustworthy
Copy link
Contributor

IMPORTANT: If you have a question, or you are not sure if you have found a bug in this package, then you are in the wrong place. Hit back in your web browser, and then open a GitHub Discussion instead. Likewise, if you are unable to provide the information requested below, open a discussion to troubleshoot your issue.

Describe the bug
Emitting to a sid from an external process (AsyncPubSubManager) will fan out the message to all the connected clients.

Expected behavior
A message is only delivered to the sid if to=sid is specified.


Hello and thank you for this beautiful piece of software! I really love the ergonomics and the excellent docs.

Please see PR #1374

@miguelgrinberg
Copy link
Owner

You can use room to address an individual client or a room. The to argument was introduced in the main server and client classes, and it appears that I missed including it in the managers.

@rustworthy
Copy link
Contributor Author

rustworthy commented Aug 18, 2024

I would honestly expect it the other way round 😅 , meaning you can use to to address an individual client or a room even if under the hood a single client is a room with one participant. This may be even more confusing, if one is using both sending to individual sids and rooms in their main app.

Also for the context, I've been building a web app that communicates with the browser-powered app: it sends notifications to the client, but can also receive certain tasks. The web app will then queue these tasks and embed a sid value as part of a task/job payload. A worker will pull the jobs from the queue, process them and inform the client (using the to=sid just like we are doing it in the main server). This is where it turned out that all the clients are receiving the report from the worker.

updated the PR

EDIT: also updated the issue title, since it turns out emitting to a specific client is possible

@rustworthy rustworthy changed the title Enable emitting to single client in AsyncPubSubManager Enable emitting to single client in managers with to=... Aug 18, 2024
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

2 participants