Browse Source

Fixed an event ordering issue. The server now only
first the connection added event after sending the
connect confirmation to the client. This prevents
a resource deadlock if the connection listener
tries to send a message to the client and the
client tries to send a response back... since the
client won't have been fully initialized yet.


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

PSp..om 14 years ago
parent
commit
a0dea25ec5
1 changed files with 4 additions and 4 deletions
  1. 4 4
      engine/src/networking/com/jme3/network/base/DefaultServer.java

+ 4 - 4
engine/src/networking/com/jme3/network/base/DefaultServer.java

@@ -312,16 +312,16 @@ public class DefaultServer implements Server
         if( addedConnection != null ) {       
             log.log( Level.INFO, "Client registered:{0}.", addedConnection );
             
-            // Now we can notify the listeners about the
-            // new connection.
-            fireConnectionAdded( addedConnection );
-                                                    
             // Send the ID back to the client letting it know it's
             // fully connected.
             m = new ClientRegistrationMessage();
             m.setId( addedConnection.getId() );
             m.setReliable(true);
             addedConnection.send(m);
+            
+            // Now we can notify the listeners about the
+            // new connection.
+            fireConnectionAdded( addedConnection );                                                   
         }            
     }