Is that possible?
Sounds like the Two Generals’ Problem
A sends message to B
B sends a “message received” message back to A
A sends an “acknowledgement received” message back to B (this step might be optional depending on your use case)
Now all parties are synchronised.
In your case, A is whoever calls broadcast
, and your Websocket client, B in the example, will need to send a confirmation up the pipe.
I would say it is not possible by definition, because broadcast!/3
sends a message to all the clients that have joined the given topic, so there is no concept of “the client”.
The way I see it, the solution is to send a message to a specific socket and not to a topic (which might map to a number of sockets), but I don’t know 1) how to do it and 2) whether the function used to send the message will return the actual result instead of always :ok
like the broadcast does.
Did you find a solution?