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
3.0
PSp..om 14 years ago
parent e511caa64f
commit 8da5e751dd
  1. 2
      engine/src/networking/com/jme3/network/Client.java
  2. 8
      engine/src/networking/com/jme3/network/base/DefaultClient.java
  3. 6
      engine/src/networking/com/jme3/network/base/DefaultServer.java

@ -59,7 +59,7 @@ public interface Client extends MessageConnection
* server or -1 if this client isn't fully connected to the * server or -1 if this client isn't fully connected to the
* server. * server.
*/ */
public long getId(); public int getId();
/** /**
* Sends a message to the server. * Sends a message to the server.

@ -55,7 +55,7 @@ public class DefaultClient implements Client
{ {
static Logger log = Logger.getLogger(DefaultClient.class.getName()); static Logger log = Logger.getLogger(DefaultClient.class.getName());
private long id = -1; private int id = -1;
private boolean isRunning = false; private boolean isRunning = false;
private Connector reliable; private Connector reliable;
private Connector fast; private Connector fast;
@ -113,7 +113,7 @@ public class DefaultClient implements Client
// Send our connection message with a generated ID until // Send our connection message with a generated ID until
// we get one back from the server. We'll hash time in // we get one back from the server. We'll hash time in
// millis and time in nanos. // 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. // Set it true here so we can send some messages.
isRunning = true; isRunning = true;
@ -140,7 +140,7 @@ public class DefaultClient implements Client
return id != -1; // for now return id != -1; // for now
} }
public long getId() public int getId()
{ {
return id; return id;
} }
@ -235,7 +235,7 @@ public class DefaultClient implements Client
// interested in and then pass on the rest. // interested in and then pass on the rest.
if( m instanceof ClientRegistrationMessage ) { if( m instanceof ClientRegistrationMessage ) {
// Then we've gotten our real id // 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 ); log.log( Level.INFO, "Connection established, id:{0}.", this.id );
fireConnected(); fireConnected();
return; return;

@ -36,7 +36,7 @@ import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.*; import java.util.*;
import java.util.concurrent.*; 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.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -58,7 +58,7 @@ public class DefaultServer implements Server
static Logger log = Logger.getLogger(DefaultServer.class.getName()); static Logger log = Logger.getLogger(DefaultServer.class.getName());
private boolean isRunning = false; private boolean isRunning = false;
private AtomicLong nextId = new AtomicLong(0); private AtomicInteger nextId = new AtomicInteger(0);
private Kernel reliable; private Kernel reliable;
private KernelAdapter reliableAdapter; private KernelAdapter reliableAdapter;
private Kernel fast; private Kernel fast;
@ -335,7 +335,7 @@ public class DefaultServer implements Server
protected class Connection implements HostedConnection protected class Connection implements HostedConnection
{ {
private long id; private int id;
private Endpoint reliable; private Endpoint reliable;
private Endpoint fast; private Endpoint fast;

Loading…
Cancel
Save