I’ve created a simple websocket application as per this example Plug — Plug v1.16.1. The idea is that when a client (specified by id) connects using the /websocket endpoint, I would register it centrally in the application (for now something simple like an agent, and then send messages to the client. My question is that when it connects, the websock interface module is created with a new pid, but I’m not sure how to use that pid to send a message to the client that created it (by connecting). How would I facilitate this communication so another process can send a message and it gets brodcast to the client
I discovered returning a push response from handle_info sends the response to the client. I’d just have to find a way to store the pids for the connected websockets and possibly link the worker processes so that I can handle failures of the process to report back to the websocket via the handle_info.
One of the tools listed in there should work for you: Matrjoschka of phoenix communication | Benjamin Milde
1 Like