-
Notifications
You must be signed in to change notification settings - Fork 85
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
Conversation
There was a problem hiding this 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() |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
…y. Azure web pub sub sockets do eventually timeout afer a couple days.
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!