aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2016-06-09 16:59:19 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2016-06-09 16:59:19 +0200
commit6518887513840471ea9c5af7e534787717e6bd82 (patch)
tree6aa4d2f8e777f25d318348a91d2c02ca62298b6b /include
parent741d4e0505c588f38a64350c1d3c53c74f7ac22c (diff)
Make possible to call a method from a binding
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 <jose.bollo@iot.bzh>
Diffstat (limited to 'include')
-rw-r--r--include/afb/afb-req-itf.h16
1 files changed, 14 insertions, 2 deletions
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)