aboutsummaryrefslogtreecommitdiffstats
path: root/src/afb-proto-ws.h
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2019-07-16 23:39:27 +0200
committerJose Bollo <jose.bollo@iot.bzh>2019-07-18 15:38:02 +0200
commit6dfeafe7e4fa582b3db3f950136bc97f8611fc6d (patch)
tree62386661fe495dd8992260c89e09757326450edc /src/afb-proto-ws.h
parent5b5968815dc672467f40ed6b49f05a590bdb8b4d (diff)
Tag broadcasted events with UUID and hop
When API have mutual dependencies, leading to loops in dependecies, broadcasting an event never ends because of the loop (see SPEC-2625). To avoid that weird flood of events, a unic identifier (UUID) is attached to broadcasted event and a tiny memory records previously broadcasted events to avoid re-sending an already sent event. The size of the memory can be set using the macro variable EVENT_BROADCAST_MEMORY_COUNT whose default value is 8. It can be reduced to 0. An other mecanism is added to limit the count of hops that a broadcasted event can do. That count can be set using the macro variable EVENT_BROADCAST_HOP_MAX whose default value is 10. Bug-AGL: SPEC-2625 Change-Id: I29550a8a5c8f5e2ffb20edc3330357a1e870c0e2 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-proto-ws.h')
-rw-r--r--src/afb-proto-ws.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/afb-proto-ws.h b/src/afb-proto-ws.h
index 312984a4..506960ea 100644
--- a/src/afb-proto-ws.h
+++ b/src/afb-proto-ws.h
@@ -29,6 +29,8 @@ struct afb_proto_ws;
struct afb_proto_ws_call;
struct afb_proto_ws_describe;
+typedef unsigned char afb_proto_ws_uuid_t[16];
+
struct afb_proto_ws_client_itf
{
/* can't be NULL */
@@ -40,7 +42,7 @@ struct afb_proto_ws_client_itf
void (*on_event_subscribe)(void *closure, void *request, const char *event_name, int event_id);
void (*on_event_unsubscribe)(void *closure, void *request, const char *event_name, int event_id);
void (*on_event_push)(void *closure, const char *event_name, int event_id, struct json_object *data);
- void (*on_event_broadcast)(void *closure, const char *event_name, struct json_object *data);
+ void (*on_event_broadcast)(void *closure, const char *event_name, struct json_object *data, const afb_proto_ws_uuid_t uuid, uint8_t hop);
};
struct afb_proto_ws_server_itf
@@ -70,7 +72,7 @@ extern int afb_proto_ws_client_describe(struct afb_proto_ws *protows, void (*cal
extern int afb_proto_ws_server_event_create(struct afb_proto_ws *protows, const char *event_name, int event_id);
extern int afb_proto_ws_server_event_remove(struct afb_proto_ws *protows, const char *event_name, int event_id);
extern int afb_proto_ws_server_event_push(struct afb_proto_ws *protows, const char *event_name, int event_id, struct json_object *data);
-extern int afb_proto_ws_server_event_broadcast(struct afb_proto_ws *protows, const char *event_name, struct json_object *data);
+extern int afb_proto_ws_server_event_broadcast(struct afb_proto_ws *protows, const char *event_name, struct json_object *data, const afb_proto_ws_uuid_t uuid, uint8_t hop);
extern void afb_proto_ws_call_addref(struct afb_proto_ws_call *call);
extern void afb_proto_ws_call_unref(struct afb_proto_ws_call *call);