![]() |
|
Uniot Core
|
| 0.8.1 |
#include <CallbackEventListener.h>
Public Types | |
| using | EventListenerCallback = std::function<void(T_topic, T_msg)> |
| Callback function type for event handling. | |
Public Types inherited from uniot::EventEntity< T_topic, T_msg, T_data > | |
| using | DataChannelCallback = std::function<void(unsigned int, bool, T_data)> |
| Callback type for handling data received from channels. | |
Public Member Functions | |
| CallbackEventListener (EventListenerCallback callback) | |
| Constructs a CallbackEventListener with the given callback function. | |
| virtual void | onEventReceived (T_topic topic, T_msg msg) |
| Handler called when an event is received. | |
Public Member Functions inherited from uniot::EventListener< T_topic, T_msg, T_data > | |
| virtual | ~EventListener ()=default |
| Virtual destructor. | |
| virtual type_id | getTypeId () const override |
| Get the type ID of this class for RTTI. | |
| EventListener * | listenToEvent (T_topic topic) |
| Subscribe to events of a specific topic. | |
| EventListener * | stopListeningToEvent (T_topic topic) |
| Unsubscribe from events of a specific topic. | |
| bool | isListeningToEvent (T_topic topic) |
| Check if this listener is subscribed to a specific topic. | |
Public Member Functions inherited from uniot::EventEmitter< T_topic, T_msg, T_data > | |
| virtual | ~EventEmitter ()=default |
| Virtual destructor to ensure proper cleanup of derived classes. | |
| void | emitEvent (T_topic topic, T_msg msg) |
| Emits an event to all registered event buses. | |
Public Member Functions inherited from uniot::EventEntity< T_topic, T_msg, T_data > | |
| virtual | ~EventEntity () |
| Destructor - disconnects from all connected EventBus instances. | |
| bool | sendDataToChannel (T_topic channel, T_data data) |
| Sends data to a specific channel on all connected EventBus instances. | |
| void | receiveDataFromChannel (T_topic channel, DataChannelCallback callback) |
| Receives data from a specific channel on all connected EventBus instances. | |
Additional Inherited Members | |
Protected Member Functions inherited from uniot::EventEntity< T_topic, T_msg, T_data > | |
| bool | connectUnique (EventBus< T_topic, T_msg, T_data > *eventBus) |
| Connects to an EventBus instance if not already connected. | |
Protected Attributes inherited from uniot::EventEntity< T_topic, T_msg, T_data > | |
| IterableQueue< EventBus< T_topic, T_msg, T_data > * > | mEventBusQueue |
| Queue of EventBus instances this entity is connected to. | |
| using uniot::CallbackEventListener< T_topic, T_msg, T_data >::EventListenerCallback = std::function<void(T_topic, T_msg)> |
Callback function type for event handling.
This function will be called when an event is received with the topic and message as parameters.
| uniot::CallbackEventListener< T_topic, T_msg, T_data >::CallbackEventListener | ( | EventListenerCallback | callback | ) |
Constructs a CallbackEventListener with the given callback function.
| callback | The function to call when an event is received. |
|
virtual |
Handler called when an event is received.
This overrides the base EventListener method and invokes the stored callback.
| topic | The topic of the received event. |
| msg | The message/payload of the received event. |
Implements uniot::EventListener< T_topic, T_msg, T_data >.