0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 20:30:23 +00:00

Add the set_options Websocket command

It allows overriding the idle_timeout option only for now.
This commit is contained in:
Loïc Hoguin 2018-11-16 13:48:15 +01:00
parent 75045637fc
commit f5015cb14b
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764
3 changed files with 59 additions and 1 deletions

View file

@ -34,6 +34,7 @@
-type commands() :: [cow_ws:frame()
| {active, boolean()}
| {deflate, boolean()}
| {set_options, map()}
].
-export_type([commands/0]).
@ -527,6 +528,14 @@ commands([{active, Active}|Tail], State, Data) when is_boolean(Active) ->
commands(Tail, State#state{active=Active}, Data);
commands([{deflate, Deflate}|Tail], State, Data) when is_boolean(Deflate) ->
commands(Tail, State#state{deflate=Deflate}, Data);
commands([{set_options, SetOpts}|Tail], State0=#state{opts=Opts}, Data) ->
State = case SetOpts of
#{idle_timeout := IdleTimeout} ->
loop_timeout(State0#state{opts=Opts#{idle_timeout => IdleTimeout}});
_ ->
State0
end,
commands(Tail, State, Data);
commands([Frame|Tail], State, Data0) ->
Data = [frame(Frame, State)|Data0],
case is_close_frame(Frame) of