From 6518887513840471ea9c5af7e534787717e6bd82 Mon Sep 17 00:00:00 2001 From: José Bollo Date: Thu, 9 Jun 2016 16:59:19 +0200 Subject: Make possible to call a method from a binding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The new request call 'afb_req_subcall' allows a binding to call the method of an other binding. Change-Id: I8538185be7a1663153a25db2bc940f9e2bdedb1a Signed-off-by: José Bollo --- include/afb/afb-req-itf.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/afb/afb-req-itf.h b/include/afb/afb-req-itf.h index 2b3bc467..3efb089d 100644 --- a/include/afb/afb-req-itf.h +++ b/include/afb/afb-req-itf.h @@ -70,6 +70,8 @@ struct afb_req_itf { int (*subscribe)(void *closure, struct afb_event event); int (*unsubscribe)(void *closure, struct afb_event event); + + void (*subcall)(void *closure, const char *api, const char *verb, struct json_object *args, void (*callback)(void*, int, struct json_object*), void *cb_closure); }; /* @@ -340,8 +342,18 @@ static inline int afb_req_unsubscribe(struct afb_req req, struct afb_event event return req.itf->unsubscribe(req.closure, event); } - - +/* + * Makes a call to the method of name 'api' / 'verb' with the object 'args'. + * This call is made in the context of the request 'req'. + * On completion, the function 'callback' is invoked with the + * 'closure' given at call and two other parameters: 'iserror' and 'result'. + * 'iserror' is a boolean that indicates if the reply is an error reply. + * 'result' is the json object of the reply. + */ +static inline void afb_req_subcall(struct afb_req req, const char *api, const char *verb, struct json_object *args, void (*callback)(void *closure, int iserror, struct json_object *result), void *closure) +{ + req.itf->subcall(req.closure, api, verb, args, callback, closure); +} /* internal use */ static inline const char *afb_req_raw(struct afb_req req, size_t *size) -- cgit 1.2.3-korg