diff options
author | José Bollo <jose.bollo@iot.bzh> | 2016-06-09 16:59:19 +0200 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2016-06-09 16:59:19 +0200 |
commit | 6518887513840471ea9c5af7e534787717e6bd82 (patch) | |
tree | 6aa4d2f8e777f25d318348a91d2c02ca62298b6b /src/afb-hreq.c | |
parent | 741d4e0505c588f38a64350c1d3c53c74f7ac22c (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 'src/afb-hreq.c')
-rw-r--r-- | src/afb-hreq.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/afb-hreq.c b/src/afb-hreq.c index 1e38b412..d1a262f7 100644 --- a/src/afb-hreq.c +++ b/src/afb-hreq.c @@ -37,6 +37,7 @@ #include "afb-msg-json.h" #include "afb-context.h" #include "afb-hreq.h" +#include "afb-subcall.h" #include "session.h" #include "verbose.h" @@ -75,6 +76,7 @@ static void req_success(struct afb_hreq *hreq, json_object *obj, const char *inf static const char *req_raw(struct afb_hreq *hreq, size_t *size); static void req_send(struct afb_hreq *hreq, const char *buffer, size_t size); static int req_subscribe_unsubscribe_error(struct afb_hreq *hreq, struct afb_event event); +static void req_subcall(struct afb_hreq *hreq, const char *api, const char *verb, struct json_object *args, void (*callback)(void*, int, struct json_object*), void *closure); const struct afb_req_itf afb_hreq_req_itf = { .json = (void*)req_json, @@ -90,7 +92,8 @@ const struct afb_req_itf afb_hreq_req_itf = { .session_close = (void*)afb_context_close, .session_set_LOA = (void*)afb_context_change_loa, .subscribe = (void*)req_subscribe_unsubscribe_error, - .unsubscribe = (void*)req_subscribe_unsubscribe_error + .unsubscribe = (void*)req_subscribe_unsubscribe_error, + .subcall = (void*)req_subcall }; static struct hreq_data *get_data(struct afb_hreq *hreq, const char *key, int create) @@ -807,6 +810,11 @@ static int req_subscribe_unsubscribe_error(struct afb_hreq *hreq, struct afb_eve return -1; } +static void req_subcall(struct afb_hreq *hreq, const char *api, const char *verb, struct json_object *args, void (*callback)(void*, int, struct json_object*), void *closure) +{ + afb_subcall(&hreq->context, api, verb, args, callback, closure, (struct afb_req){ .itf = &afb_hreq_req_itf, .closure = hreq }); +} + int afb_hreq_init_context(struct afb_hreq *hreq) { const char *uuid; |