aboutsummaryrefslogtreecommitdiffstats
path: root/src/afb-api-so.c
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2016-04-19 18:02:11 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2016-04-19 18:02:11 +0200
commit9e3afb8aa598f3e69e2c3723335507c12b4cd1f1 (patch)
tree97459a101bd4e3291547a42600c4012caf4d1274 /src/afb-api-so.c
parent46d9538587a3521caa1e3b20bf337a53ed400777 (diff)
initial event handler
Change-Id: Idb92d6de9904d050b37ef0a5d664e82573ff640d Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-api-so.c')
-rw-r--r--src/afb-api-so.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/afb-api-so.c b/src/afb-api-so.c
index c3cb08d7..88246b58 100644
--- a/src/afb-api-so.c
+++ b/src/afb-api-so.c
@@ -46,6 +46,7 @@ extern __thread sigjmp_buf *error_handler;
struct api_so_desc {
struct AFB_plugin *plugin; /* descriptor */
+ size_t apilength;
void *handle; /* context of dlopen */
struct AFB_interface interface; /* interface */
};
@@ -65,6 +66,16 @@ static const struct afb_pollmgr_itf pollmgr_itf = {
static void afb_api_so_evmgr_push(struct api_so_desc *desc, const char *name, struct json_object *object)
{
+ size_t length;
+ char *event;
+
+ assert(desc->plugin != NULL);
+ length = strlen(name);
+ event = alloca(length + 2 + desc->apilength);
+ memcpy(event, desc->plugin->prefix, desc->apilength);
+ event[desc->apilength] = '/';
+ memcpy(event + desc->apilength + 1, name, length + 1);
+ ctxClientEventSend(NULL, event, object);
}
static const struct afb_evmgr_itf evmgr_itf = {
@@ -224,6 +235,7 @@ int afb_api_so_add_plugin(const char *path)
}
/* records the plugin */
+ desc->apilength = strlen(desc->plugin->prefix);
if (afb_apis_add(desc->plugin->prefix, (struct afb_api){
.closure = desc,
.call = (void*)call}) < 0) {