[99s-extend] How to send multiple messages in response to one message from Cowboy

John Kemp john at jkemp.net
Fri Feb 8 19:34:36 CET 2013


Answering my own question - multiple messages can be sent in reply by 
including a list of 'reply' tuples in the websocket_handle response. I 
found this by looking at cowboy_websocket_handler.erl in the source tree.

-callback websocket_handle({text | binary | ping | pong, binary()}, Req, 
State)
	-> {ok, Req, State}
	| {ok, Req, State, hibernate}

	| {reply, cowboy_websocket:frame() | [cowboy_websocket:frame()], Req, 
State}
	| {reply, cowboy_websocket:frame() | [cowboy_websocket:frame()], Req, 
State, hibernate}

	| {shutdown, Req, State}
	when Req::cowboy_req:req(), State::state().

JohnK

On 02/08/2013 08:08 AM, John Kemp wrote:
> Hi,
>
> I see that with websocket_info/3 I can prompt Cowboy to send a message
> to a connected client by sending a "system message".
>
> How can I send multiple reply messages to a client which has sent a
> request?
>
> Is the way to do that by calling websocket_info/3 directly (multiple
> times) from within my websocket_handle call?
>
> Cheers,
>
> JohnK
> _______________________________________________
> Extend mailing list
> Extend at lists.ninenines.eu
> http://lists.ninenines.eu:81/listinfo/extend




More information about the Extend mailing list