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
This commit is contained in:
parent
e511caa64f
commit
8da5e751dd
@ -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.
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user