Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

40 lines (28 sloc) 1.121 kb
%%% compiled using erlc -I include src/basic_echo_callback.erl
%% Export for websocket callbacks
%% Export for apply
handle_message({text, <<"bye">>}) ->
io:format("User said bye.~n", []),
{close, normal};
handle_message({text, <<"something">>}) ->
io:format("Some action without a reply~n", []),
handle_message({text, <<"say hi later">>}) ->
io:format("saying hi in 3s.~n", []),
timer:apply_after(3000, ?MODULE, say_hi, [self()]),
{reply, {text, <<"I'll say hi in a bit...">>}};
handle_message({text, Message}) ->
io:format("basic echo handler got ~p~n", [Message]),
{reply, {text, <<Message/binary>>}};
handle_message({binary, Message}) ->
{reply, {binary, Message}};
handle_message({close, Status, _Reason}) ->
{close, Status}.
say_hi(Pid) ->
io:format("asynchronous greeting~n", []),
yaws_api:websocket_send(Pid, {text, <<"hi there!">>}).
Jump to Line
Something went wrong with that request. Please try again.