mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 04:10:24 +00:00
Document the commands based Websocket interface
The old interface with ok|reply|stop tuples is deprecated.
This commit is contained in:
parent
2b38526351
commit
3977f2b96f
13 changed files with 108 additions and 81 deletions
|
@ -10,15 +10,15 @@ init(Req, Opts) ->
|
|||
|
||||
websocket_init(State) ->
|
||||
erlang:start_timer(1000, self(), <<"Hello!">>),
|
||||
{ok, State}.
|
||||
{[], State}.
|
||||
|
||||
websocket_handle({text, Msg}, State) ->
|
||||
{reply, {text, << "That's what she said! ", Msg/binary >>}, State};
|
||||
{[{text, << "That's what she said! ", Msg/binary >>}], State};
|
||||
websocket_handle(_Data, State) ->
|
||||
{ok, State}.
|
||||
{[], State}.
|
||||
|
||||
websocket_info({timeout, _Ref, Msg}, State) ->
|
||||
erlang:start_timer(1000, self(), <<"How' you doin'?">>),
|
||||
{reply, {text, Msg}, State};
|
||||
{[{text, Msg}], State};
|
||||
websocket_info(_Info, State) ->
|
||||
{ok, State}.
|
||||
{[], State}.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue