aboutsummaryrefslogtreecommitdiffstats
path: root/src/afb-ws-json1.c
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2016-06-17 22:31:33 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2016-06-23 11:04:23 +0200
commitd8ef25780bffa6f91f013ef71b1ede908325e59d (patch)
treefb0d3aef9cdf0775dcadd2c062741519c4d4fcad /src/afb-ws-json1.c
parentb0848149c1ef5236791c0ba5196540d05d9f15fd (diff)
evt: handles broadcasting and tracking
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-ws-json1.c')
-rw-r--r--src/afb-ws-json1.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/afb-ws-json1.c b/src/afb-ws-json1.c
index 4cfc9181..9d295e78 100644
--- a/src/afb-ws-json1.c
+++ b/src/afb-ws-json1.c
@@ -44,7 +44,7 @@ struct afb_wsreq;
/* predeclaration of websocket callbacks */
static void aws_on_hangup(struct afb_ws_json1 *ws, struct afb_wsj1 *wsj1);
static void aws_on_call(struct afb_ws_json1 *ws, const char *api, const char *verb, struct afb_wsj1_msg *msg);
-static void aws_on_event(struct afb_ws_json1 *ws, const char *event, struct json_object *object);
+static void aws_on_event(struct afb_ws_json1 *ws, const char *event, int eventid, struct json_object *object);
/* predeclaration of wsreq callbacks */
static void wsreq_addref(struct afb_wsreq *wsreq);
@@ -110,6 +110,12 @@ const struct afb_req_itf afb_ws_json1_req_itf = {
.subcall = (void*)wsreq_subcall
};
+/* the interface for events */
+static const struct afb_evt_itf evt_itf = {
+ .broadcast = (void*)aws_on_event,
+ .push = (void*)aws_on_event
+};
+
/***************************************************************
****************************************************************
**
@@ -141,7 +147,7 @@ struct afb_ws_json1 *afb_ws_json1_create(int fd, struct afb_context *context, vo
if (result->wsj1 == NULL)
goto error3;
- result->listener = afb_evt_listener_create((void*)aws_on_event, result);
+ result->listener = afb_evt_listener_create(&evt_itf, result);
if (result->listener == NULL)
goto error4;
@@ -217,7 +223,7 @@ static void aws_on_call(struct afb_ws_json1 *ws, const char *api, const char *ve
wsreq_unref(wsreq);
}
-static void aws_on_event(struct afb_ws_json1 *aws, const char *event, struct json_object *object)
+static void aws_on_event(struct afb_ws_json1 *aws, const char *event, int eventid, struct json_object *object)
{
afb_wsj1_send_event_j(aws->wsj1, event, afb_msg_json_event(event, object));
}