[erlang-questions] broadcast message to all gen_server
Wed Apr 11 03:43:57 CEST 2012
yea i finally backtracked more through the code and realized you can just do
as an API call to a gen_server:cast() call. I am gonna throw this into a
spawn(fun() -> ) to get as close to "broadcast" as possible unless there is
negligible gain in doing this since its an async call anyway.
On Tue, Apr 10, 2012 at 7:09 PM, Tilman Holschuh
> And this doesn't work for you?
> It's a cast and you can supply the pid (just wondering why he explicitly
> returns ok but that doesn't matter).
> - Tilman
> On 12-04-10 03:01 PM, AD wrote:
>> the gen_server is part of the sockjs server and i was trying to not
>> modify/fork his code and leverage what is already there. Currently he uses
>> a handle_call() so was looking at handling it outside his code.
>> On Tue, Apr 10, 2012 at 4:18 PM, Tilman Holschuh
>>> On 12-04-10 12:37 PM, AD wrote:
>>> I have a situation where i am trying to handle a case where I am using
>>>> sockjs and need to send a message to each sockjs session_server (which
>>>> gen_server). I am using gproc() but I cant simply do a gproc_send() b/c
>>>> the message ends up in handle_info() instead of properly in
>>>> I have managed to work this out, when receiving a message from
>>>> rabbitmq i
>>>> do a gproc:lookup_pids() and then loop through each pid and do a
>>>> gen_server:call(PID,Message). The issue is this is a linear process, is
>>>> there a way to handle sending gen_server:call() to all the processes
>>>> concurrently ?
>>> Do you need a response from the gen_server:call? If not you could just
>>> a cast instead. Something like:
>>> [gen_server:cast(Pid, Message) || Pid<- gproc:lookup_pids()]
>>> - Tilman
>>> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions