new MessageHandler()
The handler interface for receiving messages sent from sessions to the server. This interface must be implemented by the user, to be registered via Session.messages#addHandler.
A message handler has a lifecycle that reflects the registration state on the server. This is expressed through the
callback methods. Once onClose has been closed, no further
interactions will occur.
Messages received by a handler contain the identity of the original sender.
Methods
-
onActive(unregister)
-
Called when the handler has been registered at the server and is now active.
Parameters:
Name Type Description unregister
function A function to call that will unregister and close this handler
-
onClose()
-
Called when the handler is unregistered, or the session is closed.
-
onMessage(message)
-
Handle a message that was sent by another session to the server, on a path that is a descendant of the path which this handler is registered for.
Parameters:
Name Type Description message
Session.messages.SessionMessage The received message