|
SmartFoxServer 3 C++ Client API 3.1.0-beta
Client API for SmartFoxServer 3
|
Gives a class the capability to dispatch events, and the methods to listen to them. More...
#include <Listenable.h>
Public Member Functions | |
| void | addEventListener (EventType evtType, event::EventListener listener) |
| Adds a listener that handles one event type. | |
| void | removeEventListener (EventType evtType) |
| Removes the listener of one event type. | |
| void | removeAllEventListeners () |
| Removes all the listeners that were added. | |
Gives a class the capability to dispatch events, and the methods to listen to them.
SmartFox uses it with the SFSEvent type, so these three methods are how an application registers its event handlers.
|
inline |
Adds a listener that handles one event type.
There is one listener per event type: a second call with the same type replaces the previous listener.
The listener receives the event as an ApiEvent reference. Cast it to the payload struct of the type you registered for, as listed in SFSEvent.
| evtType | the event type to listen to |
| listener | the function that handles the event |
|
inline |
Removes the listener of one event type.
Nothing happens if no listener was added for that type.
| evtType | the event type that is no longer listened to |
|
inline |
Removes all the listeners that were added.
It is useful after a disconnection, to clear all the listeners at once.