[erlang-questions] Push a message to cowboy websockets

AD straightflush@REDACTED
Mon Apr 9 02:27:57 CEST 2012


Barco,

 Looks you got it by just in case my websocket_info looks like

websocket_info(Info, Req, State) ->
    io:format("cowboy: got a websocket message ~p~n",[Info]),
    case Info of
        {_PID,?WSKey,Msg} ->
                {reply, {text, Msg}, Req, State, hibernate};
       ........
       ........

And then in my gen_servers to send a message to all clients i just do

gproc:send({p, l, ?WSKey}, {self(), ?WSKey, Msg})

Hope that helps.

-AD

On Sat, Apr 7, 2012 at 2:07 PM, Ulf Wiger <ulf@REDACTED> wrote:

>
> On 7 Apr 2012, at 16:56, Barco You wrote:
>
> thank you very much you all.
>
> But next question: how can I delete a client from the broadcast pool,
> because the gproc has only the API to unregister a process by "key" -
> unreg(Key) - and can not find unregister by Pid().
>
>
> A process can remove itself from the gproc registry using the function
> gproc:goodbye().
>
> It is not possible to have a gproc:goodbye(Pid), since this would violate
> the rule that you can only register/unregister unique names for yourself.
>
> BR,
> Ulf W
>
> Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc.
> http://feuerlabs.com
>
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120408/36827cd3/attachment.htm>


More information about the erlang-questions mailing list