Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

29 lines (23 sloc) 1.082 kb
-module(jsontest).
-export([out/1, handler/3]).
out(Arg) ->
yaws_rpc:handler_session(Arg, {?MODULE, handler}).
handler(_State, {call, subtract, Params}, _Session) ->
{Minuend, Subtrahend} = case Params of
{array, [M, S]} ->
{M, S};
Obj ->
{jsonrpc:s(Obj, "minuend"),
jsonrpc:s(Obj, "subtrahend")}
end,
{true, undefined, undefined, {response, Minuend - Subtrahend}};
handler(_State, {notification, update, {array, [1,2,3,4,5]}}, _Session) ->
false;
handler(_State, {notification, foobar, undefined}, _Session) ->
false;
handler(_State, {call, sum, {array, Params}}, _Session) ->
{true, undefined, undefined, {response, lists:sum(Params)}};
handler(_State, {notification, "notify_hello", {array, [7]}}, _Session) ->
false;
handler(_State, {call, get_data, undefined}, _Session) ->
{true, undefined, undefined, {response, {array, ["hello", 5]}}}.
Jump to Line
Something went wrong with that request. Please try again.