Question about broadcast in CloudFlare Workers Chat Demo
I just found out about CloudFlare Workers, and I found the Workers Chat Demo: https://github.com/cloudflare/workers-chat-demo. I have a question.
The
ChatRoom
Durable Object keeps track of this.session
, stores web sockets in those sessions, and uses them to broadcast messages to all the clients when a user sends a message to a chat room.
Is it really all the clients though? Unless I'm missing something, the broadcast message will be sent only to the clients associated to the sessions that that particular Worker is keeping track of.
My understanding is that the point of Workers is to have serverless backend code that auto-scales horizontally based on traffic, automatically instantiating new Workers as needed.
So if User1 and User2 are using the same chat room Room1, but they happen to be connected to web sockets handled by two different Workers, if User1 sends a message to the chat room, will User2 see the message?1 Reply
Does that mean there will never be two Workers managing the same chat room?