PresentsClient -> PresentsSession (Jamie's suggestion) and associated changes

on down the client.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5508 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2008-11-06 18:04:42 +00:00
parent a9f7175d2f
commit c69630b7e0
17 changed files with 98 additions and 101 deletions
@@ -26,13 +26,13 @@ import com.threerings.util.Name;
import com.threerings.presents.net.AuthRequest; import com.threerings.presents.net.AuthRequest;
import com.threerings.presents.server.ClientFactory; import com.threerings.presents.server.ClientFactory;
import com.threerings.presents.server.ClientResolver; import com.threerings.presents.server.ClientResolver;
import com.threerings.presents.server.PresentsClient; import com.threerings.presents.server.PresentsSession;
import com.threerings.bureau.data.BureauCredentials; import com.threerings.bureau.data.BureauCredentials;
/** /**
* Handles resolution of bureaus and passes non-bureau resolution requests through to a normal * Handles resolution of bureaus and passes non-bureau resolution requests through to a normal
* factory. For bureaus, creates base class instances {@link PresentsClient} and * factory. For bureaus, creates base class instances {@link PresentsSession} and
* {@link ClientResolver}. * {@link ClientResolver}.
* @see BureauRegistry#setDefaultClientFactory() * @see BureauRegistry#setDefaultClientFactory()
*/ */
@@ -44,12 +44,12 @@ public class BureauClientFactory implements ClientFactory
} }
// from interface ClientFactory // from interface ClientFactory
public Class<? extends PresentsClient> getClientClass (AuthRequest areq) public Class<? extends PresentsSession> getClientClass (AuthRequest areq)
{ {
// Just give bureaus a vanilla PresentsClient client for now. // Just give bureaus a vanilla PresentsSession client for now.
// TODO: will bureaus need a more tailored client? // TODO: will bureaus need a more tailored client?
if (areq.getCredentials() instanceof BureauCredentials) { if (areq.getCredentials() instanceof BureauCredentials) {
return PresentsClient.class; return PresentsSession.class;
} else { } else {
return _delegate.getClientClass(areq); return _delegate.getClientClass(areq);
} }
@@ -41,7 +41,7 @@ import com.threerings.presents.data.ClientObject;
import com.threerings.presents.dobj.RootDObjectManager; import com.threerings.presents.dobj.RootDObjectManager;
import com.threerings.presents.server.ClientManager; import com.threerings.presents.server.ClientManager;
import com.threerings.presents.server.InvocationManager; import com.threerings.presents.server.InvocationManager;
import com.threerings.presents.server.PresentsClient; import com.threerings.presents.server.PresentsSession;
import com.threerings.bureau.data.AgentObject; import com.threerings.bureau.data.AgentObject;
import com.threerings.bureau.data.BureauCodes; import com.threerings.bureau.data.BureauCodes;
@@ -125,13 +125,13 @@ public class BureauRegistry
public void init () public void init ()
{ {
_clmgr.addClientObserver(new ClientManager.ClientObserver() { _clmgr.addClientObserver(new ClientManager.ClientObserver() {
public void clientSessionDidStart (PresentsClient client) { public void clientSessionDidStart (PresentsSession client) {
String id = BureauCredentials.extractBureauId(client.getUsername()); String id = BureauCredentials.extractBureauId(client.getUsername());
if (id != null) { if (id != null) {
sessionDidStart(client, id); sessionDidStart(client, id);
} }
} }
public void clientSessionDidEnd (PresentsClient client) { public void clientSessionDidEnd (PresentsSession client) {
String id = BureauCredentials.extractBureauId(client.getUsername()); String id = BureauCredentials.extractBureauId(client.getUsername());
if (id != null) { if (id != null) {
sessionDidEnd(client, id); sessionDidEnd(client, id);
@@ -323,7 +323,7 @@ public class BureauRegistry
/** /**
* Returns the active session for a bureau of the given id. * Returns the active session for a bureau of the given id.
*/ */
public PresentsClient lookupClient (String bureauId) public PresentsSession lookupClient (String bureauId)
{ {
Bureau bureau = _bureaus.get(bureauId); Bureau bureau = _bureaus.get(bureauId);
if (bureau == null) { if (bureau == null) {
@@ -332,7 +332,7 @@ public class BureauRegistry
return bureau.client; return bureau.client;
} }
protected void sessionDidStart (PresentsClient client, String id) protected void sessionDidStart (PresentsSession client, String id)
{ {
Bureau bureau = _bureaus.get(id); Bureau bureau = _bureaus.get(id);
if (bureau == null) { if (bureau == null) {
@@ -346,7 +346,7 @@ public class BureauRegistry
bureau.client = client; bureau.client = client;
} }
protected void sessionDidEnd (PresentsClient client, String id) protected void sessionDidEnd (PresentsSession client, String id)
{ {
Bureau bureau = _bureaus.get(id); Bureau bureau = _bureaus.get(id);
if (bureau == null) { if (bureau == null) {
@@ -691,7 +691,7 @@ public class BureauRegistry
ClientObject clientObj; ClientObject clientObj;
// The client session // The client session
PresentsClient client; PresentsSession client;
// The states of the various agents allocated to this bureau // The states of the various agents allocated to this bureau
Map<AgentObject, AgentState> agentStates = Maps.newHashMap(); Map<AgentObject, AgentState> agentStates = Maps.newHashMap();
@@ -32,7 +32,7 @@ import com.threerings.presents.peer.server.PeerManager;
import com.threerings.presents.peer.server.PeerNode; import com.threerings.presents.peer.server.PeerNode;
import com.threerings.presents.server.InvocationException; import com.threerings.presents.server.InvocationException;
import com.threerings.presents.server.InvocationManager; import com.threerings.presents.server.InvocationManager;
import com.threerings.presents.server.PresentsClient; import com.threerings.presents.server.PresentsSession;
import com.threerings.presents.server.ShutdownManager; import com.threerings.presents.server.ShutdownManager;
import com.threerings.crowd.chat.client.ChatService; import com.threerings.crowd.chat.client.ChatService;
@@ -130,7 +130,7 @@ public class CrowdPeerManager extends PeerManager
} }
@Override // documentation inherited @Override // documentation inherited
protected void initClientInfo (PresentsClient client, ClientInfo info) protected void initClientInfo (PresentsSession client, ClientInfo info)
{ {
super.initClientInfo(client, info); super.initClientInfo(client, info);
((CrowdClientInfo)info).visibleName = ((CrowdClientInfo)info).visibleName =
@@ -45,8 +45,8 @@ public class CrowdObjectAccess
// documentation inherited from interface // documentation inherited from interface
public boolean allowSubscribe (DObject object, Subscriber<?> sub) public boolean allowSubscribe (DObject object, Subscriber<?> sub)
{ {
if (CrowdClient.class.isInstance(sub)) { if (CrowdSession.class.isInstance(sub)) {
ClientObject co = CrowdClient.class.cast(sub).getClientObject(); ClientObject co = CrowdSession.class.cast(sub).getClientObject();
return ((PlaceObject)object).occupants.contains(co.getOid()); return ((PlaceObject)object).occupants.contains(co.getOid());
} }
return true; return true;
@@ -31,7 +31,7 @@ import com.threerings.util.Name;
import com.threerings.presents.net.AuthRequest; import com.threerings.presents.net.AuthRequest;
import com.threerings.presents.server.ClientFactory; import com.threerings.presents.server.ClientFactory;
import com.threerings.presents.server.ClientResolver; import com.threerings.presents.server.ClientResolver;
import com.threerings.presents.server.PresentsClient; import com.threerings.presents.server.PresentsSession;
import com.threerings.presents.server.PresentsServer; import com.threerings.presents.server.PresentsServer;
import com.threerings.crowd.chat.server.ChatProvider; import com.threerings.crowd.chat.server.ChatProvider;
@@ -64,8 +64,8 @@ public class CrowdServer extends PresentsServer
// configure the client manager to use our bits // configure the client manager to use our bits
_clmgr.setClientFactory(new ClientFactory() { _clmgr.setClientFactory(new ClientFactory() {
public Class<? extends PresentsClient> getClientClass (AuthRequest areq) { public Class<? extends PresentsSession> getClientClass (AuthRequest areq) {
return CrowdClient.class; return CrowdSession.class;
} }
public Class<? extends ClientResolver> getClientResolverClass (Name username) { public Class<? extends ClientResolver> getClientResolverClass (Name username) {
return CrowdClientResolver.class; return CrowdClientResolver.class;
@@ -23,16 +23,16 @@ package com.threerings.crowd.server;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.threerings.presents.server.PresentsClient; import com.threerings.presents.server.PresentsSession;
import com.threerings.crowd.chat.server.SpeakUtil; import com.threerings.crowd.chat.server.SpeakUtil;
import com.threerings.crowd.data.BodyObject; import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.OccupantInfo; import com.threerings.crowd.data.OccupantInfo;
/** /**
* The crowd client extends the presents client with crowd-specific client handling. * Extends the presents session with crowd-specific session handling.
*/ */
public class CrowdClient extends PresentsClient public class CrowdSession extends PresentsSession
{ {
@Override @Override
protected void sessionConnectionClosed () protected void sessionConnectionClosed ()
@@ -29,7 +29,7 @@ import com.threerings.presents.dobj.RootDObjectManager;
import com.threerings.presents.server.ClientManager; import com.threerings.presents.server.ClientManager;
import com.threerings.presents.server.InvocationException; import com.threerings.presents.server.InvocationException;
import com.threerings.presents.server.InvocationManager; import com.threerings.presents.server.InvocationManager;
import com.threerings.presents.server.PresentsClient; import com.threerings.presents.server.PresentsSession;
import com.threerings.crowd.client.LocationService; import com.threerings.crowd.client.LocationService;
import com.threerings.crowd.data.BodyObject; import com.threerings.crowd.data.BodyObject;
@@ -111,7 +111,7 @@ public class LocationManager
} }
// configure the client accordingly if the place uses a custom class loader // configure the client accordingly if the place uses a custom class loader
PresentsClient client = _clmgr.getClient(source.username); PresentsSession client = _clmgr.getClient(source.username);
if (client != null) { if (client != null) {
client.setClassLoader(pmgr.getClass().getClassLoader()); client.setClassLoader(pmgr.getClass().getClassLoader());
} }
@@ -31,7 +31,7 @@ package com.threerings.presents.net;
public class AuthResponse extends DownstreamMessage public class AuthResponse extends DownstreamMessage
{ {
/** Auxilliary authentication data to be communicated to the <code> /** Auxilliary authentication data to be communicated to the <code>
* PresentsClient</code> once a session is started. This is a means by * PresentsSession</code> once a session is started. This is a means by
* which the <code>Authenticator</code> can pass information loaded from, * which the <code>Authenticator</code> can pass information loaded from,
* say, an authentication database into the runtime system to be used, for * say, an authentication database into the runtime system to be used, for
* example for permissions. */ * example for permissions. */
@@ -27,7 +27,7 @@ import com.threerings.presents.net.AuthRequest;
import com.threerings.presents.peer.net.PeerCreds; import com.threerings.presents.peer.net.PeerCreds;
import com.threerings.presents.server.ClientFactory; import com.threerings.presents.server.ClientFactory;
import com.threerings.presents.server.ClientResolver; import com.threerings.presents.server.ClientResolver;
import com.threerings.presents.server.PresentsClient; import com.threerings.presents.server.PresentsSession;
/** /**
* Handles resolution of peer servers and passes non-peer resolution requests through to a normal * Handles resolution of peer servers and passes non-peer resolution requests through to a normal
@@ -41,10 +41,10 @@ public class PeerClientFactory implements ClientFactory
} }
// documentation inherited from interface ClientFactory // documentation inherited from interface ClientFactory
public Class<? extends PresentsClient> getClientClass (AuthRequest areq) public Class<? extends PresentsSession> getClientClass (AuthRequest areq)
{ {
if (areq.getCredentials() instanceof PeerCreds) { if (areq.getCredentials() instanceof PeerCreds) {
return PeerClient.class; return PeerSession.class;
} else { } else {
return _delegate.getClientClass(areq); return _delegate.getClientClass(areq);
} }
@@ -64,7 +64,7 @@ import com.threerings.presents.data.ClientObject;
import com.threerings.presents.server.ClientManager; import com.threerings.presents.server.ClientManager;
import com.threerings.presents.server.InvocationException; import com.threerings.presents.server.InvocationException;
import com.threerings.presents.server.InvocationManager; import com.threerings.presents.server.InvocationManager;
import com.threerings.presents.server.PresentsClient; import com.threerings.presents.server.PresentsSession;
import com.threerings.presents.server.PresentsDObjectMgr; import com.threerings.presents.server.PresentsDObjectMgr;
import com.threerings.presents.server.ReportManager; import com.threerings.presents.server.ReportManager;
import com.threerings.presents.server.ShutdownManager; import com.threerings.presents.server.ShutdownManager;
@@ -643,7 +643,7 @@ public abstract class PeerManager
} }
/** /**
* Called by {@link PeerClient}s when clients subscribe to the {@link NodeObject}. * Called by {@link PeerSession}s when clients subscribe to the {@link NodeObject}.
*/ */
public void clientSubscribedToNode (int cloid) public void clientSubscribedToNode (int cloid)
{ {
@@ -651,7 +651,7 @@ public abstract class PeerManager
} }
/** /**
* Called by {@link PeerClient}s when clients unsubscribe from the {@link NodeObject}. * Called by {@link PeerSession}s when clients unsubscribe from the {@link NodeObject}.
*/ */
public void clientUnsubscribedFromNode (int cloid) public void clientUnsubscribedFromNode (int cloid)
{ {
@@ -768,7 +768,7 @@ public abstract class PeerManager
} }
// from interface ClientManager.ClientObserver // from interface ClientManager.ClientObserver
public void clientSessionDidStart (PresentsClient client) public void clientSessionDidStart (PresentsSession client)
{ {
if (ignoreClient(client)) { if (ignoreClient(client)) {
return; return;
@@ -790,7 +790,7 @@ public abstract class PeerManager
} }
// from interface ClientManager.ClientObserver // from interface ClientManager.ClientObserver
public void clientSessionDidEnd (PresentsClient client) public void clientSessionDidEnd (PresentsSession client)
{ {
if (ignoreClient(client)) { if (ignoreClient(client)) {
return; return;
@@ -872,10 +872,10 @@ public abstract class PeerManager
* the beginning and end of the client session, so this method should return the same value * the beginning and end of the client session, so this method should return the same value
* both times. * both times.
*/ */
protected boolean ignoreClient (PresentsClient client) protected boolean ignoreClient (PresentsSession client)
{ {
// if this is another peer, don't publish their info // if this is another peer, don't publish their info
return (client instanceof PeerClient); return (client instanceof PeerSession);
} }
/** /**
@@ -947,7 +947,7 @@ public abstract class PeerManager
/** /**
* Initializes the supplied client info for the supplied client. * Initializes the supplied client info for the supplied client.
*/ */
protected void initClientInfo (PresentsClient client, ClientInfo info) protected void initClientInfo (PresentsSession client, ClientInfo info)
{ {
info.username = client.getCredentials().getUsername(); info.username = client.getCredentials().getUsername();
} }
@@ -955,7 +955,7 @@ public abstract class PeerManager
/** /**
* Called when a client ends their session to clear their information from our node object. * Called when a client ends their session to clear their information from our node object.
*/ */
protected void clearClientInfo (PresentsClient client, ClientInfo info) protected void clearClientInfo (PresentsSession client, ClientInfo info)
{ {
_nodeobj.removeFromClients(info.getKey()); _nodeobj.removeFromClients(info.getKey());
} }
@@ -29,28 +29,27 @@ import com.threerings.presents.dobj.DObject;
import com.threerings.presents.net.BootstrapData; import com.threerings.presents.net.BootstrapData;
import com.threerings.presents.peer.data.NodeObject; import com.threerings.presents.peer.data.NodeObject;
import com.threerings.presents.peer.net.PeerBootstrapData; import com.threerings.presents.peer.net.PeerBootstrapData;
import com.threerings.presents.server.PresentsClient; import com.threerings.presents.server.PresentsSession;
import static com.threerings.presents.Log.log; import static com.threerings.presents.Log.log;
/** /**
* Manages a peer connection. * Manages a peer session.
*/ */
public class PeerClient extends PresentsClient public class PeerSession extends PresentsSession
{ {
/** /**
* Creates a peer client and provides it with a reference to the peer * Creates a peer session and provides it with a reference to the peer manager. This is only
* manager. This is only done by the {@link PeerClientFactory}. * done by the {@link PeerClientFactory}.
*/ */
@Inject public PeerClient (PeerManager peermgr) @Inject public PeerSession (PeerManager peermgr)
{ {
_peermgr = peermgr; _peermgr = peermgr;
} }
/** /**
* Derived client classes can override this member to create derived * Derived classes can override this member to create derived bootstrap data classes that
* bootstrap data classes that contain extra bootstrap information, if * contain extra bootstrap information, if desired.
* desired.
*/ */
@Override @Override
protected BootstrapData createBootstrapData () protected BootstrapData createBootstrapData ()
@@ -59,14 +58,12 @@ public class PeerClient extends PresentsClient
} }
/** /**
* Derived client classes can override this member to populate the * Derived classes can override this member to populate the bootstrap data with additional
* bootstrap data with additional information. They should be sure to * information. They should be sure to call <code>super.populateBootstrapData</code> before
* call <code>super.populateBootstrapData</code> before doing their * doing their own populating, however.
* own populating, however.
* *
* <p><em>Note:</em> This function will be called on the dobjmgr * <p><em>Note:</em> This function will be called on the dobjmgr thread which means that object
* thread which means that object manipulations are OK, but client * manipulations are OK, but client instance manipulations must be done carefully.
* instance manipulations must be done carefully.
*/ */
@Override @Override
protected void populateBootstrapData (BootstrapData data) protected void populateBootstrapData (BootstrapData data)
@@ -87,7 +84,7 @@ public class PeerClient extends PresentsClient
_cloid = _clobj.getOid(); _cloid = _clobj.getOid();
} }
@Override // from PresentsClient @Override // from PresentsSession
protected void subscribedToObject (DObject object) protected void subscribedToObject (DObject object)
{ {
super.subscribedToObject(object); super.subscribedToObject(object);
@@ -96,7 +93,7 @@ public class PeerClient extends PresentsClient
} }
} }
@Override // from PresentsClient @Override // from PresentsSession
protected void unsubscribedFromObject (DObject object) protected void unsubscribedFromObject (DObject object)
{ {
super.unsubscribedFromObject(object); super.unsubscribedFromObject(object);
@@ -105,14 +102,14 @@ public class PeerClient extends PresentsClient
} }
} }
@Override // from PresentsClient @Override // from PresentsSession
protected Throttle createIncomingMessageThrottle () protected Throttle createIncomingMessageThrottle ()
{ {
// more than 100 messages per second and we complain about it // more than 100 messages per second and we complain about it
return new Throttle(100, 1000L); return new Throttle(100, 1000L);
} }
@Override // from PresentsClient @Override // from PresentsSession
protected void handleThrottleExceeded () protected void handleThrottleExceeded ()
{ {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
@@ -26,15 +26,15 @@ import com.threerings.util.Name;
import com.threerings.presents.net.AuthRequest; import com.threerings.presents.net.AuthRequest;
/** /**
* Used to determine what type of {@link PresentsClient} to use to manage an authenticated client * Used to determine what type of {@link PresentsSession} to use to manage an authenticated client
* as well the type of {@link ClientResolver} to use when resolving clients' runtime data. * as well the type of {@link ClientResolver} to use when resolving clients' runtime data.
*/ */
public interface ClientFactory public interface ClientFactory
{ {
/** The default client factory. */ /** The default client factory. */
public static ClientFactory DEFAULT = new ClientFactory() { public static ClientFactory DEFAULT = new ClientFactory() {
public Class<? extends PresentsClient> getClientClass (AuthRequest areq) { public Class<? extends PresentsSession> getClientClass (AuthRequest areq) {
return PresentsClient.class; return PresentsSession.class;
} }
public Class<? extends ClientResolver> getClientResolverClass (Name username) { public Class<? extends ClientResolver> getClientResolverClass (Name username) {
return ClientResolver.class; return ClientResolver.class;
@@ -42,10 +42,10 @@ public interface ClientFactory
}; };
/** /**
* Returns the {@link PresentsClient} derived class to use for the session that authenticated * Returns the {@link PresentsSession} derived class to use for the session that authenticated
* with the supplied request. * with the supplied request.
*/ */
Class<? extends PresentsClient> getClientClass (AuthRequest areq); Class<? extends PresentsSession> getClientClass (AuthRequest areq);
/** /**
* Returns the {@link ClientResolver} derived class to use to resolve a client with the * Returns the {@link ClientResolver} derived class to use to resolve a client with the
@@ -88,13 +88,13 @@ public class ClientManager
/** /**
* Called when a client has authenticated and been resolved and has started their session. * Called when a client has authenticated and been resolved and has started their session.
*/ */
void clientSessionDidStart (PresentsClient client); void clientSessionDidStart (PresentsSession client);
/** /**
* Called when a client has logged off or been forcibly logged off due to inactivity and * Called when a client has logged off or been forcibly logged off due to inactivity and
* has thus ended their session. * has thus ended their session.
*/ */
void clientSessionDidEnd (PresentsClient client); void clientSessionDidEnd (PresentsSession client);
} }
/** /**
@@ -119,7 +119,7 @@ public class ClientManager
} }
/** /**
* Configures the injector we'll use to resolve dependencies for {@link PresentsClient} * Configures the injector we'll use to resolve dependencies for {@link PresentsSession}
* instances. * instances.
*/ */
public void setInjector (Injector injector) public void setInjector (Injector injector)
@@ -134,7 +134,7 @@ public class ClientManager
// inform all of our clients that they are being shut down // inform all of our clients that they are being shut down
synchronized (_usermap) { synchronized (_usermap) {
for (PresentsClient pc : _usermap.values()) { for (PresentsSession pc : _usermap.values()) {
try { try {
pc.shutdown(); pc.shutdown();
} catch (Exception e) { } catch (Exception e) {
@@ -146,7 +146,7 @@ public class ClientManager
} }
/** /**
* Configures the client manager with a factory for creating {@link PresentsClient} and {@link * Configures the client manager with a factory for creating {@link PresentsSession} and {@link
* ClientResolver} classes for authenticated client connections. * ClientResolver} classes for authenticated client connections.
*/ */
public void setClientFactory (ClientFactory factory) public void setClientFactory (ClientFactory factory)
@@ -216,7 +216,7 @@ public class ClientManager
* Returns the client instance that manages the client session for the specified authentication * Returns the client instance that manages the client session for the specified authentication
* username or null if that client is not currently connected to the server. * username or null if that client is not currently connected to the server.
*/ */
public PresentsClient getClient (Name authUsername) public PresentsSession getClient (Name authUsername)
{ {
synchronized (_usermap) { synchronized (_usermap) {
return _usermap.get(authUsername); return _usermap.get(authUsername);
@@ -375,7 +375,7 @@ public class ClientManager
Name username = creds.getUsername(); Name username = creds.getUsername();
// see if a client is already registered with these credentials // see if a client is already registered with these credentials
PresentsClient client = getClient(username); PresentsSession client = getClient(username);
if (client != null) { if (client != null) {
log.info("Resuming session [username=" + username + ", conn=" + conn + "]."); log.info("Resuming session [username=" + username + ", conn=" + conn + "].");
@@ -401,7 +401,7 @@ public class ClientManager
public synchronized void connectionFailed (Connection conn, IOException fault) public synchronized void connectionFailed (Connection conn, IOException fault)
{ {
// remove the client from the connection map // remove the client from the connection map
PresentsClient client = _conmap.remove(conn); PresentsSession client = _conmap.remove(conn);
if (client != null) { if (client != null) {
log.info("Unmapped failed client [client=" + client + ", conn=" + conn + log.info("Unmapped failed client [client=" + client + ", conn=" + conn +
", fault=" + fault + "]."); ", fault=" + fault + "].");
@@ -419,7 +419,7 @@ public class ClientManager
public synchronized void connectionClosed (Connection conn) public synchronized void connectionClosed (Connection conn)
{ {
// remove the client from the connection map // remove the client from the connection map
PresentsClient client = _conmap.remove(conn); PresentsSession client = _conmap.remove(conn);
if (client != null) { if (client != null) {
log.debug("Unmapped client [client=" + client + ", conn=" + conn + "]."); log.debug("Unmapped client [client=" + client + ", conn=" + conn + "].");
// let the client know the connection went away // let the client know the connection went away
@@ -448,7 +448,7 @@ public class ClientManager
* Called by the client instance when it has started its session. This is called from the * Called by the client instance when it has started its session. This is called from the
* dobjmgr thread. * dobjmgr thread.
*/ */
protected void clientSessionDidStart (final PresentsClient client) protected void clientSessionDidStart (final PresentsSession client)
{ {
// let the observers know // let the observers know
_clobservers.apply(new ObserverList.ObserverOp<ClientObserver>() { _clobservers.apply(new ObserverList.ObserverOp<ClientObserver>() {
@@ -463,11 +463,11 @@ public class ClientManager
* Called by the client instance when the client requests a logoff. This is called from the * Called by the client instance when the client requests a logoff. This is called from the
* dobjmgr thread. * dobjmgr thread.
*/ */
protected void clientSessionDidEnd (final PresentsClient client) protected void clientSessionDidEnd (final PresentsSession client)
{ {
// remove the client from the username map // remove the client from the username map
Name username = client.getCredentials().getUsername(); Name username = client.getCredentials().getUsername();
PresentsClient rc; PresentsSession rc;
synchronized (_usermap) { synchronized (_usermap) {
rc = _usermap.remove(username); rc = _usermap.remove(username);
} }
@@ -497,12 +497,12 @@ public class ClientManager
*/ */
protected void flushClients () protected void flushClients ()
{ {
List<PresentsClient> victims = Lists.newArrayList(); List<PresentsSession> victims = Lists.newArrayList();
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
// first build a list of our victims // first build a list of our victims
synchronized (_usermap) { synchronized (_usermap) {
for (PresentsClient client : _usermap.values()) { for (PresentsSession client : _usermap.values()) {
if (client.checkExpired(now)) { if (client.checkExpired(now)) {
victims.add(client); victims.add(client);
} }
@@ -510,7 +510,7 @@ public class ClientManager
} }
// now end their sessions // now end their sessions
for (PresentsClient client : victims) { for (PresentsSession client : victims) {
try { try {
log.info("Client expired, ending session [client=" + client + log.info("Client expired, ending session [client=" + client +
", dtime=" + (now-client.getNetworkStamp()) + "ms]."); ", dtime=" + (now-client.getNetworkStamp()) + "ms].");
@@ -549,14 +549,14 @@ public class ClientManager
protected ClientOp _clop; protected ClientOp _clop;
} }
/** Used to resolve dependencies in {@link PresentsClient} instances that we create. */ /** Used to resolve dependencies in {@link PresentsSession} instances that we create. */
protected Injector _injector; protected Injector _injector;
/** A mapping from auth username to client instances. */ /** A mapping from auth username to client instances. */
protected Map<Name, PresentsClient> _usermap = Maps.newHashMap(); protected Map<Name, PresentsSession> _usermap = Maps.newHashMap();
/** A mapping from connections to client instances. */ /** A mapping from connections to client instances. */
protected Map<Connection, PresentsClient> _conmap = Maps.newHashMap(); protected Map<Connection, PresentsSession> _conmap = Maps.newHashMap();
/** A mapping from usernames to client object instances. */ /** A mapping from usernames to client object instances. */
protected Map<Name, ClientObject> _objmap = Maps.newHashMap(); protected Map<Name, ClientObject> _objmap = Maps.newHashMap();
@@ -575,7 +575,7 @@ public class PresentsDObjectMgr
/** /**
* Tests if the event processing thread is still running. This is required by the * Tests if the event processing thread is still running. This is required by the
* {@link ConnectionManager} to ensure messages posted just before or during shutdown are sent. * ConnectionManager to ensure messages posted just before or during shutdown are sent.
*/ */
public synchronized boolean isRunning () public synchronized boolean isRunning ()
{ {
@@ -74,8 +74,8 @@ public class PresentsObjectAccess
{ {
boolean allowed = true; boolean allowed = true;
// if the subscriber is a client, ensure that they are this same user // if the subscriber is a client, ensure that they are this same user
if (PresentsClient.class.isInstance(sub)) { if (PresentsSession.class.isInstance(sub)) {
PresentsClient client = PresentsClient.class.cast(sub); PresentsSession client = PresentsSession.class.cast(sub);
allowed = (client.getClientObject() == object); allowed = (client.getClientObject() == object);
if (!allowed) { if (!allowed) {
log.warning("Refusing ClientObject subscription request " + log.warning("Refusing ClientObject subscription request " +
@@ -83,10 +83,10 @@ import static com.threerings.presents.Log.log;
* without synchronization. This does not overlap with its other client duties which are called * without synchronization. This does not overlap with its other client duties which are called
* from the conmgr thread and therefore also need not be synchronized. * from the conmgr thread and therefore also need not be synchronized.
*/ */
public class PresentsClient public class PresentsSession
implements MessageHandler, ClientResolutionListener implements MessageHandler, ClientResolutionListener
{ {
/** Used by {@link PresentsClient#setUsername} to report success or failure. */ /** Used by {@link PresentsSession#setUsername} to report success or failure. */
public static interface UserChangeListener public static interface UserChangeListener
{ {
/** Called when the new client object has been resolved and the new client object reported /** Called when the new client object has been resolved and the new client object reported
@@ -106,7 +106,7 @@ public class PresentsClient
} }
/** /**
* Returns the credentials used to authenticate this client. * Returns the credentials used to authenticate this session.
*/ */
public Credentials getCredentials () public Credentials getCredentials ()
{ {
@@ -114,7 +114,7 @@ public class PresentsClient
} }
/** /**
* Returns the time zone in which this client is operating. * Returns the time zone in which the client is operating.
*/ */
public TimeZone getTimeZone () public TimeZone getTimeZone ()
{ {
@@ -122,8 +122,8 @@ public class PresentsClient
} }
/** /**
* Returns true if this client has been disconnected for sufficiently long that its session * Returns true if this session has been disconnected for sufficiently long that it should be
* should be forcibly ended. * forcibly ended.
*/ */
public boolean checkExpired (long now) public boolean checkExpired (long now)
{ {
@@ -164,7 +164,7 @@ public class PresentsClient
} }
/** /**
* Configures this client with a custom class loader that will be used when unserializing * Configures this session with a custom class loader that will be used when unserializing
* classes from the network. * classes from the network.
*/ */
public void setClassLoader (ClassLoader loader) public void setClassLoader (ClassLoader loader)
@@ -966,7 +966,7 @@ public class PresentsClient
/** /**
* Dispatch the supplied message for the specified client. * Dispatch the supplied message for the specified client.
*/ */
void dispatch (PresentsClient client, UpstreamMessage mge); void dispatch (PresentsSession client, UpstreamMessage mge);
} }
/** /**
@@ -974,7 +974,7 @@ public class PresentsClient
*/ */
protected static class SubscribeDispatcher implements MessageDispatcher protected static class SubscribeDispatcher implements MessageDispatcher
{ {
public void dispatch (PresentsClient client, UpstreamMessage msg) public void dispatch (PresentsSession client, UpstreamMessage msg)
{ {
SubscribeRequest req = (SubscribeRequest)msg; SubscribeRequest req = (SubscribeRequest)msg;
// log.info("Subscribing [client=" + client + ", oid=" + req.getOid() + "]."); // log.info("Subscribing [client=" + client + ", oid=" + req.getOid() + "].");
@@ -989,7 +989,7 @@ public class PresentsClient
*/ */
protected static class UnsubscribeDispatcher implements MessageDispatcher protected static class UnsubscribeDispatcher implements MessageDispatcher
{ {
public void dispatch (PresentsClient client, UpstreamMessage msg) public void dispatch (PresentsSession client, UpstreamMessage msg)
{ {
UnsubscribeRequest req = (UnsubscribeRequest)msg; UnsubscribeRequest req = (UnsubscribeRequest)msg;
int oid = req.getOid(); int oid = req.getOid();
@@ -1009,7 +1009,7 @@ public class PresentsClient
*/ */
protected static class ForwardEventDispatcher implements MessageDispatcher protected static class ForwardEventDispatcher implements MessageDispatcher
{ {
public void dispatch (PresentsClient client, UpstreamMessage msg) public void dispatch (PresentsSession client, UpstreamMessage msg)
{ {
ForwardEventRequest req = (ForwardEventRequest)msg; ForwardEventRequest req = (ForwardEventRequest)msg;
DEvent fevt = req.getEvent(); DEvent fevt = req.getEvent();
@@ -1036,7 +1036,7 @@ public class PresentsClient
*/ */
protected static class PingDispatcher implements MessageDispatcher protected static class PingDispatcher implements MessageDispatcher
{ {
public void dispatch (PresentsClient client, UpstreamMessage msg) public void dispatch (PresentsSession client, UpstreamMessage msg)
{ {
// send a pong response using the transport with which the message was received // send a pong response using the transport with which the message was received
PingRequest req = (PingRequest)msg; PingRequest req = (PingRequest)msg;
@@ -1049,7 +1049,7 @@ public class PresentsClient
*/ */
protected static class ThrottleUpdatedDispatcher implements MessageDispatcher protected static class ThrottleUpdatedDispatcher implements MessageDispatcher
{ {
public void dispatch (final PresentsClient client, UpstreamMessage msg) public void dispatch (final PresentsSession client, UpstreamMessage msg)
{ {
log.debug("Client ACKed throttle update", "client", client); log.debug("Client ACKed throttle update", "client", client);
client.throttleUpdated(); client.throttleUpdated();
@@ -1061,7 +1061,7 @@ public class PresentsClient
*/ */
protected static class LogoffDispatcher implements MessageDispatcher protected static class LogoffDispatcher implements MessageDispatcher
{ {
public void dispatch (final PresentsClient client, UpstreamMessage msg) public void dispatch (final PresentsSession client, UpstreamMessage msg)
{ {
log.debug("Client requested logoff", "client", client); log.debug("Client requested logoff", "client", client);
client.safeEndSession(); client.safeEndSession();
@@ -32,7 +32,7 @@ import com.google.inject.Injector;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import com.threerings.presents.dobj.RootDObjectManager; import com.threerings.presents.dobj.RootDObjectManager;
import com.threerings.presents.server.PresentsClient; import com.threerings.presents.server.PresentsSession;
import com.threerings.presents.server.ShutdownManager; import com.threerings.presents.server.ShutdownManager;
import com.threerings.bureau.data.AgentObject; import com.threerings.bureau.data.AgentObject;
@@ -199,7 +199,7 @@ public class RegistryTester
{ {
if (_rng1.nextInt(100) < _killBureauChance) { if (_rng1.nextInt(100) < _killBureauChance) {
log.info("Killing a bureau"); log.info("Killing a bureau");
PresentsClient bureau = getRandomBureau(); PresentsSession bureau = getRandomBureau();
if (bureau == null) { if (bureau == null) {
log.info("No bureaus to kill right now"); log.info("No bureaus to kill right now");
return; return;
@@ -221,7 +221,7 @@ public class RegistryTester
} }
} }
protected PresentsClient getRandomBureau () protected PresentsSession getRandomBureau ()
{ {
boolean[] tried = new boolean[_numBureaus]; boolean[] tried = new boolean[_numBureaus];
for (int dead = 0; dead < _numBureaus;) { for (int dead = 0; dead < _numBureaus;) {
@@ -230,7 +230,7 @@ public class RegistryTester
continue; continue;
} }
String id = "test-" + (index + 1); String id = "test-" + (index + 1);
PresentsClient client = _bureauReg.lookupClient(id); PresentsSession client = _bureauReg.lookupClient(id);
if (client == null) { if (client == null) {
++dead; ++dead;
} else { } else {