Package com.tenio.core.event.implement
Class EventManager
java.lang.Object
com.tenio.common.logger.AbstractLogger
com.tenio.common.logger.SystemLogger
com.tenio.core.event.implement.EventManager
@NotThreadSafe
public final class EventManager
extends com.tenio.common.logger.SystemLogger
This class for managing events and these subscribers.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clear all subscribers and these corresponding events.emit
(ServerEvent event, Object... params) Emit an event with its parameters.boolean
hasSubscriber
(ServerEvent event) Check if an event has any subscribers or not.static EventManager
void
on
(ServerEvent event, Subscriber subscriber) Add a subscriber's handler.void
Collect all subscribers and these corresponding events.Methods inherited from class com.tenio.common.logger.SystemLogger
debug, trace, trace
Methods inherited from class com.tenio.common.logger.AbstractLogger
buildgen, error, error, info, info, info, info, info, info, info, info
-
Method Details
-
newInstance
-
emit
Emit an event with its parameters.- Parameters:
event
- seeServerEvent
params
- a list parameters of this event- Returns:
- the event result (the response of its subscribers), see
Object
or null - See Also:
-
on
Add a subscriber's handler.- Parameters:
event
- seeServerEvent
subscriber
- seeSubscriber
-
subscribe
public void subscribe()Collect all subscribers and these corresponding events. -
hasSubscriber
Check if an event has any subscribers or not.- Parameters:
event
- seeServerEvent
- Returns:
- true if an event has any subscribers
-
clear
public void clear()Clear all subscribers and these corresponding events.
-