Skip to content
Newer
Older
100644 29 lines (23 sloc) 1.06 KB
15454bc @vinoski JSON-RPC 2.0 support
vinoski authored May 1, 2011
1 -module(jsontest).
2 -export([out/1, handler/3]).
3
4 out(Arg) ->
5 yaws_rpc:handler_session(Arg, {?MODULE, handler}).
6
7 handler(_State, {call, subtract, Params}, _Session) ->
8 {Minuend, Subtrahend} = case Params of
9 {array, [M, S]} ->
10 {M, S};
11 Obj ->
12 {jsonrpc:s(Obj, "minuend"),
13 jsonrpc:s(Obj, "subtrahend")}
14 end,
15 {true, undefined, undefined, {response, Minuend - Subtrahend}};
16 handler(_State, {notification, update, {array, [1,2,3,4,5]}}, _Session) ->
17 false;
18 handler(_State, {notification, foobar, undefined}, _Session) ->
19 false;
20 handler(_State, {call, sum, {array, Params}}, _Session) ->
21 {true, undefined, undefined, {response, lists:sum(Params)}};
22 handler(_State, {notification, "notify_hello", {array, [7]}}, _Session) ->
23 false;
24 handler(_State, {call, get_data, undefined}, _Session) ->
25 {true, undefined, undefined, {response, {array, ["hello", 5]}}}.
26
27
28
Something went wrong with that request. Please try again.