diff options
author | José Bollo <jose.bollo@iot.bzh> | 2016-06-17 22:31:33 +0200 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2016-06-23 11:04:23 +0200 |
commit | d8ef25780bffa6f91f013ef71b1ede908325e59d (patch) | |
tree | fb0d3aef9cdf0775dcadd2c062741519c4d4fcad /src/afb-svc.c | |
parent | b0848149c1ef5236791c0ba5196540d05d9f15fd (diff) |
evt: handles broadcasting and tracking
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-svc.c')
-rw-r--r-- | src/afb-svc.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/afb-svc.c b/src/afb-svc.c index 03ff4b84..95617d5d 100644 --- a/src/afb-svc.c +++ b/src/afb-svc.c @@ -64,7 +64,7 @@ struct svc_req }; /* functions for services */ -static void svc_on_event(struct afb_svc *svc, const char *event, struct json_object *object); +static void svc_on_event(struct afb_svc *svc, const char *event, int eventid, struct json_object *object); static void svc_call(struct afb_svc *svc, const char *api, const char *verb, struct json_object *args, void (*callback)(void*, int, struct json_object*), void *closure); @@ -73,6 +73,12 @@ static const struct afb_service_itf service_itf = { .call = (void*)svc_call }; +/* the interface for events */ +static const struct afb_evt_itf evt_itf = { + .broadcast = (void*)svc_on_event, + .push = (void*)svc_on_event +}; + /* functions for requests of services */ static void svcreq_addref(struct svc_req *svcreq); static void svcreq_unref(struct svc_req *svcreq); @@ -130,7 +136,7 @@ struct afb_svc *afb_svc_create(int share_session, int (*init)(struct afb_service if (on_event == NULL) svc->listener = NULL; else { - svc->listener = afb_evt_listener_create((void*)svc_on_event, svc); + svc->listener = afb_evt_listener_create(&evt_itf, svc); if (svc->listener == NULL) goto error3; } @@ -156,7 +162,7 @@ error: /* * Propagates the event to the service */ -static void svc_on_event(struct afb_svc *svc, const char *event, struct json_object *object) +static void svc_on_event(struct afb_svc *svc, const char *event, int eventid, struct json_object *object) { svc->on_event(event, object); } |