Ignore peer clients, and scan through the client info set when removing because
we can't rely on building a new client info at session end time because the client's ClientObject will have been destroyed. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4250 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -35,7 +35,7 @@ public class NodeObject extends DObject
|
|||||||
// AUTO-GENERATED: FIELDS END
|
// AUTO-GENERATED: FIELDS END
|
||||||
|
|
||||||
/** Contains information on all clients connected to this node. */
|
/** Contains information on all clients connected to this node. */
|
||||||
public DSet<ClientInfo> clients;
|
public DSet<ClientInfo> clients = new DSet<ClientInfo>();
|
||||||
|
|
||||||
// AUTO-GENERATED: METHODS START
|
// AUTO-GENERATED: METHODS START
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ import com.samskivert.jdbc.ConnectionProvider;
|
|||||||
import com.samskivert.util.Interval;
|
import com.samskivert.util.Interval;
|
||||||
import com.samskivert.util.Invoker;
|
import com.samskivert.util.Invoker;
|
||||||
|
|
||||||
|
import com.threerings.util.Name;
|
||||||
|
|
||||||
import com.threerings.presents.client.Client;
|
import com.threerings.presents.client.Client;
|
||||||
import com.threerings.presents.client.ClientObserver;
|
import com.threerings.presents.client.ClientObserver;
|
||||||
import com.threerings.presents.dobj.ObjectAccessException;
|
import com.threerings.presents.dobj.ObjectAccessException;
|
||||||
@@ -149,6 +151,11 @@ public class PeerManager
|
|||||||
// documentation inherited from interface ClientManager.ClientObserver
|
// documentation inherited from interface ClientManager.ClientObserver
|
||||||
public void clientSessionDidStart (PresentsClient client)
|
public void clientSessionDidStart (PresentsClient client)
|
||||||
{
|
{
|
||||||
|
// if this is another peer, don't publish their info
|
||||||
|
if (client instanceof PeerClient) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// create and publish a ClientInfo record for this client
|
// create and publish a ClientInfo record for this client
|
||||||
ClientInfo clinfo = createClientInfo();
|
ClientInfo clinfo = createClientInfo();
|
||||||
initClientInfo(client, clinfo);
|
initClientInfo(client, clinfo);
|
||||||
@@ -169,18 +176,23 @@ public class PeerManager
|
|||||||
// documentation inherited from interface ClientManager.ClientObserver
|
// documentation inherited from interface ClientManager.ClientObserver
|
||||||
public void clientSessionDidEnd (PresentsClient client)
|
public void clientSessionDidEnd (PresentsClient client)
|
||||||
{
|
{
|
||||||
// we create a new client info for this client so that we can support
|
// if this is another peer, don't worry about it
|
||||||
// derived classes overriding the value we use for the DSet key
|
if (client instanceof PeerClient) {
|
||||||
ClientInfo clinfo = createClientInfo();
|
return;
|
||||||
initClientInfo(client, clinfo);
|
|
||||||
|
|
||||||
// sanity check
|
|
||||||
if (!_nodeobj.clients.containsKey(clinfo.getKey())) {
|
|
||||||
log.warning("Session ended for unregistered client " +
|
|
||||||
"[info=" + clinfo + "].");
|
|
||||||
} else {
|
|
||||||
_nodeobj.removeFromClients(clinfo.getKey());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// we scan through the list instead of relying on ClientInfo.getKey()
|
||||||
|
// because we want derived classes to be able to override that for
|
||||||
|
// lookups that happen way more frequently than logging off
|
||||||
|
Name username = client.getCredentials().getUsername();
|
||||||
|
for (ClientInfo clinfo : _nodeobj.clients) {
|
||||||
|
if (clinfo.username.equals(username)) {
|
||||||
|
_nodeobj.removeFromClients(clinfo.getKey());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.warning("Session ended for unregistered client " +
|
||||||
|
"[who=" + username + "].");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user