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

A new sample showing how to do WebPubSub groups in python. #334

Merged
merged 7 commits into from
Feb 21, 2022

Conversation

lovettchris
Copy link
Contributor

@lovettchris lovettchris commented Feb 4, 2022

This sample helps stitch together some different things to make a nice fully bidirectional communication channel using Web Pub Sub groups.

I used this code to implement a realtime messaging system to connect various distributed components of this system: https://github.com/microsoft/ada/tree/main/AdaKiosk and it has been up and running for a couple weeks now, it works great!

Copy link
Member

@vicancy vicancy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's super nice! Thanks for the contribution!

async def _send_receive(self, msg):
data = json.dumps(msg)
await self.web_socket.send(data)
response = await self.web_socket.recv()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is possible that the message received is not necessarily the ack of the message you send. For example, when someone else just published a message to the group.

Copy link
Contributor Author

@lovettchris lovettchris Feb 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well the _send_receive method is private (starts with underscore) so you are not supposed to use it. It is only used once during the setup in the connect method were it needs to check joingroup returned an ack response. After that the client of the WebPubSubGroup can only do fire and forget, and add a add_listener to receive out of band messages from others. If the user wants to do message correlation they will have to do it in their own payloads.

@vicancy vicancy merged commit b24accb into Azure:main Feb 21, 2022
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

Successfully merging this pull request may close these issues.

2 participants