From 7839f1367194813c70d7e223a476f96a62b298ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 24 Aug 2016 17:25:33 +0200 Subject: More 2.0 documentation updates Still incomplete. --- doc/src/guide/sub_protocols.asciidoc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'doc/src/guide/sub_protocols.asciidoc') diff --git a/doc/src/guide/sub_protocols.asciidoc b/doc/src/guide/sub_protocols.asciidoc index 63fd52b..5332eec 100644 --- a/doc/src/guide/sub_protocols.asciidoc +++ b/doc/src/guide/sub_protocols.asciidoc @@ -16,8 +16,8 @@ is handled by the sub protocol. [source,erlang] ---- -init(Req, _Opts) -> - {cowboy_websocket, Req, #state{}}. +init(Req, State) -> + {cowboy_websocket, Req, State}. ---- The return value may also have a `Timeout` value and/or the @@ -29,10 +29,12 @@ The following snippet switches to the `my_protocol` sub protocol, sets the timeout value to 5 seconds and enables hibernation: +// @todo Yeah maybe what we really need is an Opts map. + [source,erlang] ---- -init(Req, _Opts) -> - {my_protocol, Req, #state{}, 5000, hibernate}. +init(Req, State) -> + {my_protocol, Req, State, 5000, hibernate}. ---- If a sub protocol does not make use of these options, it should -- cgit v1.2.3