[erlang-questions] Push a message to cowboy websockets
Fri Mar 16 17:20:01 CET 2012
The general idea is to have your websocket handler register itself using
gproc (or through a central gen_server) inside the websocket_init/3
callback, and then have your service push messages to all registered
handlers which you can then catch in websocket_info/3.
I mention gproc because it's infinitely easier with it, as you only have
to register all your processes under one property and then send a
message to that property which will multicast it to all registered
processes. And when your websocket closes, gproc takes care of removing
your process from the list of registered processes, so you really have
to worry only about 2 lines of code to do everything you need.
On 03/16/2012 05:11 PM, AD wrote:
> I have cowboy setup and working to send/receive websockets over a
> socket connection. I am trying to figure out how to initiate a message
> server side over that channel (without it just being a reply). I am
> envisioning exposing a webservice on the cowboy service that would then
> push a message to all connected users (or maybe a subset based on some
> Does anyone know if this is possible and if so how to implement?
> erlang-questions mailing list
More information about the erlang-questions