Added a log INFO message for when messages are dispatched

and no listeners are registered to receive it.


git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7154 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
PSp..om 14 years ago
parent d3364b4622
commit 858925182e
  1. 12
      engine/src/networking/com/jme3/network/base/MessageListenerRegistry.java

@ -34,6 +34,8 @@ package com.jme3.network.base;
import java.util.*;
import java.util.concurrent.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.jme3.network.Message;
import com.jme3.network.MessageListener;
@ -47,6 +49,8 @@ import com.jme3.network.MessageListener;
*/
public class MessageListenerRegistry<S> implements MessageListener<S>
{
static Logger log = Logger.getLogger(MessageListenerRegistry.class.getName());
private List<MessageListener<? super S>> listeners = new CopyOnWriteArrayList<MessageListener<? super S>>();
private Map<Class,List<MessageListener<? super S>>> typeListeners
= new ConcurrentHashMap<Class,List<MessageListener<? super S>>>();
@ -57,12 +61,20 @@ public class MessageListenerRegistry<S> implements MessageListener<S>
public void messageReceived( S source, Message m )
{
boolean delivered = false;
for( MessageListener<? super S> l : listeners ) {
l.messageReceived( source, m );
delivered = true;
}
for( MessageListener<? super S> l : getListeners(m.getClass(),false) ) {
l.messageReceived( source, m );
delivered = true;
}
if( !delivered ) {
log.log( Level.INFO, "Received message had no registered listeners: {0}", m );
}
}

Loading…
Cancel
Save