1:- module(jsonrpc_methods, [
2 server_method/3,
3 find_handler/3
4 ]). 5
6:- use_module('./errors'). 7
8:- meta_predicate
9 server_method(:,:,:),
10 declared_server_method(:,:,:). 11
12:- dynamic declared_server_method/3. 13
14server_method(Server, Method, Module:Handler) :-
15 Clause = declared_server_method(Server, Method, Module:Handler),
16 ( Clause ; assertz(Clause) ).
17
18find_handler(Server,MethodName, Module:Handler) :-
19 atom_string(Method,MethodName),
20 (declared_server_method(_MServer:Server, _MMethod:Method, Module:Handler)
21 -> true
22 ; throw(unknown_method(Method))
23 )