Selaa lähdekoodia

Fix client message listeners threading. They may be
called by either the UDP or TCP thread but it will
not be at the same time.


git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7067 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

PSp..om 14 vuotta sitten
vanhempi
commit
16c6b13564

+ 6 - 1
engine/src/networking/com/jme3/network/base/DefaultClient.java

@@ -305,7 +305,12 @@ public class DefaultClient implements Client
             close();               
         }
     
-        messageListeners.messageReceived( this, m );
+        // Make sure client MessageListeners are called single-threaded
+        // since it could receive messages from the TCP and UDP
+        // thread simultaneously.
+        synchronized( this ) {
+            messageListeners.messageReceived( this, m );
+        }
     }
  
     protected class Redispatch implements MessageListener