From 2374aa7e07327acf8737823a75c1bf9bdfeafca4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Tue, 23 Aug 2011 16:24:02 +0200 Subject: Add WebSocket drafts 7, 8, 9 and 10 implementation The implementation is only partial for now but should work for all browsers implementing it. --- README.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 5a4315f..04a927c 100644 --- a/README.md +++ b/README.md @@ -195,12 +195,14 @@ websocket_init(TransportName, Req, _Opts) -> erlang:start_timer(1000, self(), <<"Hello!">>), {ok, Req, undefined_state}. -websocket_handle(Msg, Req, State) -> - {reply, << "That's what she said! ", Msg/binary >>, Req, 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_info({timeout, _Ref, Msg}, Req, State) -> erlang:start_timer(1000, self(), <<"How' you doin'?">>), - {reply, Msg, Req, State}; + {reply, {text, Msg}, Req, State}; websocket_info(_Info, Req, State) -> {ok, Req, State}. @@ -212,6 +214,12 @@ Of course you can have an HTTP handler doing both HTTP and Websocket handling, but for the sake of this example we're ignoring the HTTP part entirely. +As the Websocket protocol is still a draft the API is subject to change +regularly when support to the most recent drafts gets added. Features may +be added, changed or removed before the protocol gets finalized. Cowboy +tries to implement all drafts transparently and give a single interface to +handle them all, however. + Using Cowboy with other protocols --------------------------------- -- cgit v1.2.3