![]() |
|
Uniot Core
|
| 0.8.1 |
#include <EventListener.h>
Public Member Functions | |
| 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. | |
| virtual void | onEventReceived (T_topic topic, T_msg msg)=0 |
| Handler called when an event is received. | |
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 | |
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. | |
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. | |
|
virtualdefault |
Virtual destructor.
|
inlineoverridevirtual |
Get the type ID of this class for RTTI.
| type_id | The unique type identifier for this EventListener specialization |
Reimplemented from uniot::EventEmitter< T_topic, T_msg, T_data >.
| bool uniot::EventListener< T_topic, T_msg, T_data >::isListeningToEvent | ( | T_topic | topic | ) |
Check if this listener is subscribed to a specific topic.
| topic | The topic to check |
| true | The listener is subscribed to the topic |
| false | The listener is not subscribed to the topic |
| EventListener< T_topic, T_msg, T_data > * uniot::EventListener< T_topic, T_msg, T_data >::listenToEvent | ( | T_topic | topic | ) |
Subscribe to events of a specific topic.
| topic | The topic to listen to |
| EventListener* | Pointer to this instance for method chaining |
|
pure virtual |
Handler called when an event is received.
This method must be implemented by derived classes to handle incoming events for topics that this listener has subscribed to.
| topic | The topic of the received event |
| msg | The message payload of the received event |
Implemented in uniot::CallbackEventListener< T_topic, T_msg, T_data >, uniot::CallbackEventListener< unsigned int, int, Bytes >, uniot::LispDevice, uniot::MQTTKit, uniot::NetworkController, and uniot::unLisp.
| EventListener< T_topic, T_msg, T_data > * uniot::EventListener< T_topic, T_msg, T_data >::stopListeningToEvent | ( | T_topic | topic | ) |
Unsubscribe from events of a specific topic.
| topic | The topic to stop listening to |
| EventListener* | Pointer to this instance for method chaining |