diff options
author | José Bollo <jose.bollo@iot.bzh> | 2016-10-14 15:13:43 +0200 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2016-10-14 15:13:43 +0200 |
commit | 91d08eedaa810edfd38dcb8ce67c66813e5e3dce (patch) | |
tree | 26ef779d40ebb7d38af10ff3e87ca6e0db05306a /src/afb-evt.c | |
parent | 98a5bca16007a7c4740c4326ef83768d034aed3e (diff) |
event: add ability to get the event name
Change-Id: Iecfeb4ab07c07715093d729710669abecee722de
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-evt.c')
-rw-r--r-- | src/afb-evt.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/afb-evt.c b/src/afb-evt.c index 4924b8cb..d8853b9d 100644 --- a/src/afb-evt.c +++ b/src/afb-evt.c @@ -94,12 +94,14 @@ struct afb_evt_watch { static int evt_broadcast(struct afb_evt_event *evt, struct json_object *obj); static int evt_push(struct afb_evt_event *evt, struct json_object *obj); static void evt_destroy(struct afb_evt_event *evt); +static const char *evt_name(struct afb_evt_event *evt); /* the interface for events */ static struct afb_event_itf afb_evt_event_itf = { .broadcast = (void*)evt_broadcast, .push = (void*)evt_push, - .drop = (void*)evt_destroy + .drop = (void*)evt_destroy, + .name = (void*)evt_name }; /* head of the list of listeners */ @@ -144,8 +146,8 @@ int afb_evt_broadcast(const char *event, struct json_object *object) } /* - * Broadcasts the event 'evt' with its 'object' - * 'object' is released (like json_object_put) + * Pushes the event 'evt' with 'obj' to its listeners + * 'obj' is released (like json_object_put) * Returns the count of listener taht received the event. */ static int evt_push(struct afb_evt_event *evt, struct json_object *obj) @@ -169,6 +171,14 @@ static int evt_push(struct afb_evt_event *evt, struct json_object *obj) } /* + * Returns the name associated to the event 'evt'. + */ +static const char *evt_name(struct afb_evt_event *evt) +{ + return evt->name; +} + +/* * remove the 'watch' */ static void remove_watch(struct afb_evt_watch *watch) |