87d9a444c45083090c8b0fe19603c212971e8465
[AGL/documentation.git] / docs / 4_APIs_and_Services / 4.3_Application_Framework_Binder / 3_Binder_references / 5_Functions_of_class_afb_event.md
1 ---
2 edit_link: ''
3 title: Functions of class afb_event
4 origin_url: >-
5   https://git.automotivelinux.org/src/app-framework-binder/plain/docs/reference-v3/func-event.md?h=master
6 ---
7
8 <!-- WARNING: This file is generated by fetch_docs.js using /home/boron/Documents/AGL/docs-webtemplate/site/_data/tocs/apis_services/master/app-framework-binder-developer-guides-api-services-book.yml -->
9
10 Functions of class **afb_event**
11 ==============================
12
13 ## General functions
14
15 ### afb_event_is_valid
16
17 ```C
18 /**
19  * Checks whether the 'event' is valid or not.
20  *
21  * @param event the event to check
22  *
23  * @return 0 if not valid or 1 if valid.
24  */
25 int afb_event_is_valid(
26                         afb_event_t event);
27 ```
28
29 ### afb_event_name
30
31 ```C
32 /**
33  * Gets the name associated to 'event'.
34  *
35  * @param event the event whose name is requested
36  *
37  * @return the name of the event
38  *
39  * The returned name can be used until call to 'afb_event_unref'.
40  * It shouldn't be freed.
41  */
42 const char *afb_event_name(
43                         afb_event_t event);
44 ```
45
46 ### afb_event_unref
47
48 ```C
49 /**
50  * Decrease the count of references to 'event'.
51  * Call this function when the evenid is no more used.
52  * It destroys the event_x2 when the reference count falls to zero.
53  *
54  * @param event the event
55  */
56 void afb_event_unref(
57                         afb_event_t event);
58 ```
59
60 ### afb_event_addref
61
62 ```C
63 /**
64  * Increases the count of references to 'event'
65  *
66  * @param event the event
67  *
68  * @return the event
69  */
70 afb_event_t *afb_event_addref(
71                         afb_event_t event);
72 ```
73
74 ## Pushing functions
75
76 ### afb_event_broadcast
77
78 ```C
79 /**
80  * Broadcasts widely an event of 'event' with the data 'object'.
81  * 'object' can be NULL.
82  *
83  * For convenience, the function calls 'json_object_put' for 'object'.
84  * Thus, in the case where 'object' should remain available after
85  * the function returns, the function 'json_object_get' shall be used.
86  *
87  * @param event the event to broadcast
88  * @param object the companion object to associate to the broadcasted event (can be NULL)
89  *
90  * @return 0 in case of success or -1 in case of error
91  */
92 int afb_event_broadcast(
93                         afb_event_t event,
94                         struct json_object *object);
95 ```
96
97 ### afb_event_push
98
99 ```C
100 /**
101  * Pushes an event of 'event' with the data 'object' to its observers.
102  * 'object' can be NULL.
103  *
104  * For convenience, the function calls 'json_object_put' for 'object'.
105  * Thus, in the case where 'object' should remain available after
106  * the function returns, the function 'json_object_get' shall be used.
107  *
108  * @param event the event to push
109  * @param object the companion object to associate to the pushed event (can be NULL)
110  *
111  * @Return
112  *   *  1 if at least one client listen for the event
113  *   *  0 if no more client listen for the event
114  *   * -1 in case of error (the event can't be delivered)
115  */
116 int afb_event_push(
117                         afb_event_t event,
118                         struct json_object *object);
119 ```
120