@ SuppressWarnings ( "unchecked" ) private void dispatchMessage ( ArrayListMultimap < Integer , MessageListener > listenerMap , Message message ) { List < MessageListener > messageListeners ; // If the message is a Channel Message, hit the channel based listeners first. if ( message instanceof ChannelMessage ) { messageListeners = listenerMap . get ( ( ( ChannelMessage ) message ) . getChannelInt ( ) ) ; if ( messageListeners != null ) { for ( MessageListener listener : messageListeners ) { listener . messageReceived ( message ) ; } } } // Then send the message to any listeners registered to all channels // or to listeners for messages that do not support channels. messageListeners = listenerMap . get ( null ) ; if ( messageListeners != null ) { for ( MessageListener listener : messageListeners ) { listener . messageReceived ( message ) ; } } }
Dispatch a message to the corresponding listener arrays in the listener map