Thank you. That is exactly what I needed.
On 4/1/2013 4:56 PM, Steve Vinoski wrote:
> On Mon, Apr 1, 2013 at 4:29 AM, Martin Dimitrov <mrtndimitrov@...:
>> In our app, we have a gen_server that contains in its state a list of
>> Pids of all websockets workers. The workers have state. When something
>> triggers in the app, we want to notify interested in this event workers.
>> Their state determines where should a message to the client be sent.
>> So how can we accomplish this? If I call gen_server:cast/2 for each pid,
>> how can the worker pick the message? On the updated Websockets page in
>> the documentation, I don't see an option to override handle_cast.
> Rather than casting to the websocket gen_server process, you could just
> send it a message, which would end up in the gen_server's handle_info
> function. If your websocket callback module exports a handle_info/2 fun,
> that message will be passed on to your callback module via that function
> along with the worker state, and then the worker can decide whether or not
> to send a message to the client.
> See the handle_info/2 fun description here: