aboutsummaryrefslogtreecommitdiffstats
path: root/examples/websocket
diff options
context:
space:
mode:
authorWiteman Zheng <[email protected]>2016-08-21 21:31:54 +0800
committerLoïc Hoguin <[email protected]>2016-08-22 09:44:42 +0200
commitb9ad02d3057e78ff82dacbd38042e33073c4bc75 (patch)
treec1db4fe8c51b97d76dc361b5c7b66f96dbc18363 /examples/websocket
parentc750dd76b4367200123227fa9f8c145c64589906 (diff)
downloadcowboy-b9ad02d3057e78ff82dacbd38042e33073c4bc75.tar.gz
cowboy-b9ad02d3057e78ff82dacbd38042e33073c4bc75.tar.bz2
cowboy-b9ad02d3057e78ff82dacbd38042e33073c4bc75.zip
Fix websocket example
Diffstat (limited to 'examples/websocket')
-rw-r--r--examples/websocket/src/ws_handler.erl26
1 files changed, 13 insertions, 13 deletions
diff --git a/examples/websocket/src/ws_handler.erl b/examples/websocket/src/ws_handler.erl
index 69d8d7b..209d4bc 100644
--- a/examples/websocket/src/ws_handler.erl
+++ b/examples/websocket/src/ws_handler.erl
@@ -1,24 +1,24 @@
-module(ws_handler).
-export([init/2]).
--export([websocket_init/2]).
--export([websocket_handle/3]).
--export([websocket_info/3]).
+-export([websocket_init/1]).
+-export([websocket_handle/2]).
+-export([websocket_info/2]).
init(Req, Opts) ->
{cowboy_websocket, Req, Opts}.
-websocket_init(Req, State) ->
+websocket_init(State) ->
erlang:start_timer(1000, self(), <<"Hello!">>),
- {ok, Req, State}.
+ {ok, State}.
-websocket_handle({text, Msg}, Req, State) ->
- {reply, {text, << "That's what she said! ", Msg/binary >>}, Req, State};
-websocket_handle(_Data, Req, State) ->
- {ok, Req, State}.
+websocket_handle({text, Msg}, State) ->
+ {reply, {text, << "That's what she said! ", Msg/binary >>}, State};
+websocket_handle(_Data, State) ->
+ {ok, State}.
-websocket_info({timeout, _Ref, Msg}, Req, State) ->
+websocket_info({timeout, _Ref, Msg}, State) ->
erlang:start_timer(1000, self(), <<"How' you doin'?">>),
- {reply, {text, Msg}, Req, State};
-websocket_info(_Info, Req, State) ->
- {ok, Req, State}.
+ {reply, {text, Msg}, State};
+websocket_info(_Info, State) ->
+ {ok, State}.