OSDN Git Service

Client ID is now just an int. If users connect once
authorPSpeed42@gmail.com <PSpeed42@gmail.com@75d07b2b-3a1a-0410-a2c5-0572b91ccdca>
Fri, 18 Mar 2011 19:36:29 +0000 (19:36 +0000)
committerPSpeed42@gmail.com <PSpeed42@gmail.com@75d07b2b-3a1a-0410-a2c5-0572b91ccdca>
Fri, 18 Mar 2011 19:36:29 +0000 (19:36 +0000)
a millisecond for almost 25 days straight then it will
eventually wrap.  I think that's ok.

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

engine/src/networking/com/jme3/network/Client.java
engine/src/networking/com/jme3/network/base/DefaultClient.java
engine/src/networking/com/jme3/network/base/DefaultServer.java

index 7e362b4..013eb57 100644 (file)
@@ -59,7 +59,7 @@ public interface Client extends MessageConnection
      *  server or -1 if this client isn't fully connected to the
      *  server.
      */
-    public long getId();     
+    public int getId();     
  
     /**
      *  Sends a message to the server.
index 3536dff..417b084 100644 (file)
@@ -55,7 +55,7 @@ public class DefaultClient implements Client
 {
     static Logger log = Logger.getLogger(DefaultClient.class.getName());
     
-    private long id = -1;
+    private int id = -1;
     private boolean isRunning = false;
     private Connector reliable;
     private Connector fast;
@@ -113,7 +113,7 @@ public class DefaultClient implements Client
         // Send our connection message with a generated ID until
         // we get one back from the server.  We'll hash time in
         // millis and time in nanos.
-        long tempId = System.currentTimeMillis() ^ System.nanoTime();
+        long tempId = System.currentTimeMillis() + System.nanoTime();
 
         // Set it true here so we can send some messages.
         isRunning = true;        
@@ -140,7 +140,7 @@ public class DefaultClient implements Client
         return id != -1; // for now
     }     
 
-    public long getId()
+    public int getId()
     {   
         return id;
     }     
@@ -235,7 +235,7 @@ public class DefaultClient implements Client
         // interested in and then pass on the rest.
         if( m instanceof ClientRegistrationMessage ) {
             // Then we've gotten our real id
-            this.id = ((ClientRegistrationMessage)m).getId();
+            this.id = (int)((ClientRegistrationMessage)m).getId();
             log.log( Level.INFO, "Connection established, id:{0}.", this.id );
             fireConnected();
             return;
index 345168f..41870fd 100644 (file)
@@ -36,7 +36,7 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.*;
 import java.util.concurrent.*;
-import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -58,7 +58,7 @@ public class DefaultServer implements Server
     static Logger log = Logger.getLogger(DefaultServer.class.getName());
     
     private boolean isRunning = false;
-    private AtomicLong nextId = new AtomicLong(0);
+    private AtomicInteger nextId = new AtomicInteger(0);
     private Kernel reliable;
     private KernelAdapter reliableAdapter;
     private Kernel fast;
@@ -335,7 +335,7 @@ public class DefaultServer implements Server
 
     protected class Connection implements HostedConnection
     {
-        private long id;
+        private int id;
         private Endpoint reliable;
         private Endpoint fast;