diff --git a/jme3-networking/src/main/java/com/jme3/network/base/DefaultClient.java b/jme3-networking/src/main/java/com/jme3/network/base/DefaultClient.java index 9881830a8..3e76f8be7 100644 --- a/jme3-networking/src/main/java/com/jme3/network/base/DefaultClient.java +++ b/jme3-networking/src/main/java/com/jme3/network/base/DefaultClient.java @@ -389,6 +389,7 @@ public class DefaultClient implements Client protected void startServices() { + log.fine("Starting client services."); // Let the services know we are finally started services.start(); } @@ -447,6 +448,10 @@ public class DefaultClient implements Client protected void dispatch( Message m ) { + if( log.isLoggable(Level.FINER) ) { + log.log(Level.FINER, "{0} received:{1}", new Object[]{this, m}); + } + // Pull off the connection management messages we're // interested in and then pass on the rest. if( m instanceof ClientRegistrationMessage ) { diff --git a/jme3-networking/src/main/java/com/jme3/network/base/DefaultServer.java b/jme3-networking/src/main/java/com/jme3/network/base/DefaultServer.java index 5c62733e8..e95c0f97f 100644 --- a/jme3-networking/src/main/java/com/jme3/network/base/DefaultServer.java +++ b/jme3-networking/src/main/java/com/jme3/network/base/DefaultServer.java @@ -326,6 +326,10 @@ public class DefaultServer implements Server protected void dispatch( HostedConnection source, Message m ) { + if( log.isLoggable(Level.FINER) ) { + log.log(Level.FINER, "{0} received:{1}", new Object[]{source, m}); + } + if( source == null ) { messageListeners.messageReceived( source, m ); } else { diff --git a/jme3-networking/src/main/java/com/jme3/network/base/MessageListenerRegistry.java b/jme3-networking/src/main/java/com/jme3/network/base/MessageListenerRegistry.java index f151e1c84..4a2e40491 100644 --- a/jme3-networking/src/main/java/com/jme3/network/base/MessageListenerRegistry.java +++ b/jme3-networking/src/main/java/com/jme3/network/base/MessageListenerRegistry.java @@ -50,26 +50,34 @@ import java.util.logging.Logger; */ public class MessageListenerRegistry implements MessageListener { - static Logger log = Logger.getLogger(MessageListenerRegistry.class.getName()); + static final Logger log = Logger.getLogger(MessageListenerRegistry.class.getName()); - private List> listeners = new CopyOnWriteArrayList>(); - private Map>> typeListeners + private final List> listeners = new CopyOnWriteArrayList>(); + private final Map>> typeListeners = new ConcurrentHashMap>>(); public MessageListenerRegistry() { } + @Override public void messageReceived( S source, Message m ) { boolean delivered = false; + boolean trace = log.isLoggable(Level.FINER); for( MessageListener l : listeners ) { + if( trace ) { + log.log(Level.FINER, "Delivering {0} to:{1}", new Object[]{m, l}); + } l.messageReceived( source, m ); delivered = true; } for( MessageListener l : getListeners(m.getClass(),false) ) { + if( trace ) { + log.log(Level.FINER, "Delivering {0} to:{1}", new Object[]{m, l}); + } l.messageReceived( source, m ); delivered = true; }