aboutsummaryrefslogtreecommitdiffstats
path: root/docs/reference-v3/func-event.md
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2018-06-19 20:16:28 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2018-06-22 09:48:48 +0200
commit525e9eaa644ca92fad23adfbb7c3119ae8b57a30 (patch)
tree41de59627ccc937450daf4da6488efd4f4b2f3c2 /docs/reference-v3/func-event.md
parent9e15212d26916f59fae2be6d9e618ae9b75a4f40 (diff)
Improve documentation of api v3
The documentation is improved to reflect the new version. Tune the options Change-Id: I894c3db3bc0c10e89db66a9a51a9ad049bb8c0c4 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'docs/reference-v3/func-event.md')
-rw-r--r--docs/reference-v3/func-event.md108
1 files changed, 108 insertions, 0 deletions
diff --git a/docs/reference-v3/func-event.md b/docs/reference-v3/func-event.md
new file mode 100644
index 00000000..90c172d8
--- /dev/null
+++ b/docs/reference-v3/func-event.md
@@ -0,0 +1,108 @@
+Functions of class afb_event_t
+==============================
+
+## General functions
+
+### afb_event_is_valid
+
+```C
+/**
+ * Checks whether the 'event' is valid or not.
+ *
+ * @param event the event to check
+ *
+ * @return 0 if not valid or 1 if valid.
+ */
+int afb_event_is_valid(
+ afb_event_t event);
+```
+
+### afb_event_name
+
+```C
+/**
+ * Gets the name associated to 'event'.
+ *
+ * @param event the event whose name is requested
+ *
+ * @return the name of the event
+ *
+ * The returned name can be used until call to 'afb_event_unref'.
+ * It shouldn't be freed.
+ */
+const char *afb_event_name(
+ afb_event_t event);
+```
+
+### afb_event_unref
+
+```C
+/**
+ * Decrease the count of references to 'event'.
+ * Call this function when the evenid is no more used.
+ * It destroys the event_x2 when the reference count falls to zero.
+ *
+ * @param event the event
+ */
+void afb_event_unref(
+ afb_event_t event);
+```
+
+### afb_event_addref
+
+```C
+/**
+ * Increases the count of references to 'event'
+ *
+ * @param event the event
+ *
+ * @return the event
+ */
+afb_event_t *afb_event_addref(
+ afb_event_t event);
+```
+
+## Pushing functions
+
+### afb_event_broadcast
+
+```C
+/**
+ * Broadcasts widely an event of 'event' with the data 'object'.
+ * 'object' can be NULL.
+ *
+ * For convenience, the function calls 'json_object_put' for 'object'.
+ * Thus, in the case where 'object' should remain available after
+ * the function returns, the function 'json_object_get' shall be used.
+ *
+ * @param event the event to broadcast
+ * @param object the companion object to associate to the broadcasted event (can be NULL)
+ *
+ * @return the count of clients that received the event.
+ */
+int afb_event_broadcast(
+ afb_event_t event,
+ struct json_object *object);
+```
+
+### afb_event_push
+
+```C
+/**
+ * Pushes an event of 'event' with the data 'object' to its observers.
+ * 'object' can be NULL.
+ *
+ * For convenience, the function calls 'json_object_put' for 'object'.
+ * Thus, in the case where 'object' should remain available after
+ * the function returns, the function 'json_object_get' shall be used.
+ *
+ * @param event the event to push
+ * @param object the companion object to associate to the pushed event (can be NULL)
+ *
+ * @return the count of clients that received the event.
+ */
+int afb_event_push(
+ afb_event_t event,
+ struct json_object *object);
+```
+