public void addListener ( Telegraph listener , int msg ) { Array < Telegraph > listeners = msgListeners . get ( msg ) ; if ( listeners == null ) { // Associate an empty unordered array with the message code listeners = new Array < Telegraph > ( false , 16 ) ; msgListeners . put ( msg , listeners ) ; } listeners . add ( listener ) ; // Dispatch messages from registered providers Array < TelegramProvider > providers = msgProviders . get ( msg ) ; if ( providers != null ) { for ( int i = 0 , n = providers . size ; i < n ; i ++ ) { TelegramProvider provider = providers . get ( i ) ; Object info = provider . provideMessageInfo ( msg , listener ) ; if ( info != null ) { Telegraph sender = ClassReflection . isInstance ( Telegraph . class , provider ) ? ( Telegraph ) provider : null ; dispatchMessage ( 0 , sender , listener , msg , info , false ) ; } } } }
Registers a listener for the specified message code . Messages without an explicit receiver are broadcasted to all its registered listeners .