From 8da5e751dd77506a484a35a96c101c80c928d76a Mon Sep 17 00:00:00 2001 From: "PSp..om" Date: Fri, 18 Mar 2011 19:36:29 +0000 Subject: [PATCH] Client ID is now just an int. If users connect once a millisecond for almost 25 days straight then it will eventually wrap. I think that's ok. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7025 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- engine/src/networking/com/jme3/network/Client.java | 2 +- .../networking/com/jme3/network/base/DefaultClient.java | 8 ++++---- .../networking/com/jme3/network/base/DefaultServer.java | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/engine/src/networking/com/jme3/network/Client.java b/engine/src/networking/com/jme3/network/Client.java index 7e362b47e..013eb57a8 100644 --- a/engine/src/networking/com/jme3/network/Client.java +++ b/engine/src/networking/com/jme3/network/Client.java @@ -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. diff --git a/engine/src/networking/com/jme3/network/base/DefaultClient.java b/engine/src/networking/com/jme3/network/base/DefaultClient.java index 3536dffa8..417b0848d 100644 --- a/engine/src/networking/com/jme3/network/base/DefaultClient.java +++ b/engine/src/networking/com/jme3/network/base/DefaultClient.java @@ -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; diff --git a/engine/src/networking/com/jme3/network/base/DefaultServer.java b/engine/src/networking/com/jme3/network/base/DefaultServer.java index 345168f56..41870fd09 100644 --- a/engine/src/networking/com/jme3/network/base/DefaultServer.java +++ b/engine/src/networking/com/jme3/network/base/DefaultServer.java @@ -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;