public interface MessageListener
MendelMessage
instances produced by a MessageRouter
.Modifier and Type | Method and Description |
---|---|
void |
onConnect(NetworkDestination endpoint)
Called when a connection is established with a remote endpoint.
|
void |
onDisconnect(NetworkDestination endpoint)
Called when the MessageListener has been disconnected from a remote
endpoint.
|
void |
onMessage(MendelMessage message)
Called when a message is ready to be processed.
|
void onMessage(MendelMessage message)
MessageRouter
instance). To avoid
hurting performance, the implementation of onMessage must be lightweight.
In fact, blocking in this method implementation can cause serious
problems.
An example use case could involve placing incoming messages in a blocking queue and then having another thread process them. If the queue gets too full, then it may be appropriate to block here (thus blocking the Selector thread) to slow the rate of incoming messages from the network.
message
- MendelMessage that was received; null if the connection
has been terminated.void onConnect(NetworkDestination endpoint)
void onDisconnect(NetworkDestination endpoint)