doc: Tiny improvement
[src/app-framework-binder.git] / docs / reference-v3 / func-service.md
1 Functions of class **afb_service**
2 ==============================
3
4 All the functions of the class **afb_daemon** use the default api.
5 This are internally aliased to the corresponding legacy function of
6 class **afb_api**.
7
8 ```C
9 /**
10  * Calls the 'verb' of the 'api' with the arguments 'args' and 'verb' in the name of the binding.
11  * The result of the call is delivered to the 'callback' function with the 'callback_closure'.
12  *
13  * For convenience, the function calls 'json_object_put' for 'args'.
14  * Thus, in the case where 'args' should remain available after
15  * the function returns, the function 'json_object_get' shall be used.
16  *
17  * The 'callback' receives 3 arguments:
18  *  1. 'closure' the user defined closure pointer 'callback_closure',
19  *  2. 'status' a status being 0 on success or negative when an error occured,
20  *  2. 'result' the resulting data as a JSON object.
21  *
22  * @param api      The api name of the method to call
23  * @param verb     The verb name of the method to call
24  * @param args     The arguments to pass to the method
25  * @param callback The to call on completion
26  * @param callback_closure The closure to pass to the callback
27  *
28  * @see also 'afb_req_subcall'
29  */
30 void afb_service_call(
31         const char *api,
32         const char *verb,
33         struct json_object *args,
34         void (*callback)(void*closure, int status, struct json_object *result),
35         void *callback_closure);
36
37 /**
38  * Calls the 'verb' of the 'api' with the arguments 'args' and 'verb' in the name of the binding.
39  * 'result' will receive the response.
40  *
41  * For convenience, the function calls 'json_object_put' for 'args'.
42  * Thus, in the case where 'args' should remain available after
43  * the function returns, the function 'json_object_get' shall be used.
44  *
45  * @param api      The api name of the method to call
46  * @param verb     The verb name of the method to call
47  * @param args     The arguments to pass to the method
48  * @param result   Where to store the result - should call json_object_put on it -
49  *
50  * @returns 0 in case of success or a negative value in case of error.
51  *
52  * @see also 'afb_req_subcall'
53  */
54 int afb_service_call_sync(
55         const char *api,
56         const char *verb,
57         struct json_object *args,
58         struct json_object **result);
59 ```