Registers a method or function (hereafter, the "message listener") to be executed when the specified type of message is received from the server. The message can be a built-in UPC message, or a custom message sent to the client by a server-side module or by another client via the sendMessage() method of the Room, RoomManager, Client, ClientManager, or Server classes. Messages listeners are executed in the order they were added.
Typically, MessageManager.addMessageListener method is not used to register listeners for messages sent via Room.sendMessage method. Messages sent to a single room via Room's sendMessage() method are normally handled by listeners registered using the Room class's addMessageListener() method instead of MessageManager's addMessageListener(). The Room class's version of addMessageListener() provides a convenient wrapper for the functionality provided by MessageManager's addMessageListener().
MessageManager's addMessageListener() method can be used to register listeners that handle messages centrally for a group of rooms. For example, suppose a multi-room chat application displays a notification icon when a new message is received in any room. To catch all incoming messages for all rooms, the application registers a single, centralized method for all "CHAT" messages.
The name of the message the listener is registering to receive.
The function or method that will be invoked when the specified message is received. The rules describing the required datatypes of the listener's parameters are listed under the addMessageListener() method documentation.
A list of room IDs. If the message was sent to any of the rooms in the list, the listener is executed. Otherwise, the listener is not executed. Applies to messages sent to rooms only, not to messages sent to specific individual clients or the entire server.
Returns the number of messages that have been received by the MessageManager. Used for statistics tracking and load testing.
Returns the number of messages that have been sent by the MessageManager. Used for statistics tracking and load testing.
Returns the number of messages that have been sent and received by the MessageManager. Used for statistics tracking and load testing.
Returns a Boolean indicating whether the specified listener function is currently registered to receive message notifications for the specified message.
Unregisters a message listener method that was earlier registered for message notifications via addMessageListener().
Note that by default, all message listeners are automatically removed when the connection to the server is closed.
Creates and sends a UPC-formatted message to the server. This method is used internally to send UPC-formatted messages to the server. Any UPC-formatted response from the server will trigger a ConnectionEvent.RECEIVED_UPC event.
The MessageManager class provides a set of services related to sending and receiving messages between the client and server. Each connection has only one MessageManager, which is created automatically, and can be accessed via getMessageManager() method.