aboutsummaryrefslogtreecommitdiffstats
path: root/test/handlers/ws_set_options_commands_h.erl
diff options
context:
space:
mode:
Diffstat (limited to 'test/handlers/ws_set_options_commands_h.erl')
-rw-r--r--test/handlers/ws_set_options_commands_h.erl19
1 files changed, 15 insertions, 4 deletions
diff --git a/test/handlers/ws_set_options_commands_h.erl b/test/handlers/ws_set_options_commands_h.erl
index 88d4e72..1ab0af4 100644
--- a/test/handlers/ws_set_options_commands_h.erl
+++ b/test/handlers/ws_set_options_commands_h.erl
@@ -11,10 +11,21 @@ init(Req, RunOrHibernate) ->
{cowboy_websocket, Req, RunOrHibernate,
#{idle_timeout => infinity}}.
-websocket_handle(Frame={text, <<"idle_timeout_short">>}, State=run) ->
- {[{set_options, #{idle_timeout => 500}}, Frame], State};
-websocket_handle(Frame={text, <<"idle_timeout_short">>}, State=hibernate) ->
- {[{set_options, #{idle_timeout => 500}}, Frame], State, hibernate}.
+%% Set the idle_timeout option dynamically.
+websocket_handle({text, <<"idle_timeout_short">>}, State=run) ->
+ {[{set_options, #{idle_timeout => 500}}], State};
+websocket_handle({text, <<"idle_timeout_short">>}, State=hibernate) ->
+ {[{set_options, #{idle_timeout => 500}}], State, hibernate};
+%% Set the max_frame_size option dynamically.
+websocket_handle({text, <<"max_frame_size_small">>}, State=run) ->
+ {[{set_options, #{max_frame_size => 1000}}], State};
+websocket_handle({text, <<"max_frame_size_small">>}, State=hibernate) ->
+ {[{set_options, #{max_frame_size => 1000}}], State, hibernate};
+%% We just echo binary frames.
+websocket_handle(Frame={binary, _}, State=run) ->
+ {[Frame], State};
+websocket_handle(Frame={binary, _}, State=hibernate) ->
+ {[Frame], State, hibernate}.
websocket_info(_Info, State) ->
{[], State}.