Debian Codegraph @

test/ws_SUITE_data/ws_timeout_cancel.erl

raw
1 %% Feel free to use, reuse and abuse the code in this file.
2
3 -module(ws_timeout_cancel).
4
5 -export([init/2]).
6 -export([websocket_handle/2]).
7 -export([websocket_info/2]).
8
9 init(Req, _) ->
10 erlang:start_timer(500, self(), should_not_cancel_timer),
11 {cowboy_websocket, Req, undefined, #{
12 idle_timeout => 1000
13 }}.
14
15 websocket_handle({text, Data}, State) ->
16 {[{text, Data}], State};
17 websocket_handle({binary, Data}, State) ->
18 {[{binary, Data}], State}.
19
20 websocket_info(_Info, State) ->
21 erlang:start_timer(500, self(), should_not_cancel_timer),
22 {[], State}.