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:
@@ -26,13 +26,13 @@ import com.threerings.util.Name;
|
||||
import com.threerings.presents.net.AuthRequest;
|
||||
import com.threerings.presents.server.ClientFactory;
|
||||
import com.threerings.presents.server.ClientResolver;
|
||||
import com.threerings.presents.server.PresentsClient;
|
||||
import com.threerings.presents.server.PresentsSession;
|
||||
|
||||
import com.threerings.bureau.data.BureauCredentials;
|
||||
|
||||
/**
|
||||
* 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}.
|
||||
* @see BureauRegistry#setDefaultClientFactory()
|
||||
*/
|
||||
@@ -44,12 +44,12 @@ public class BureauClientFactory implements 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?
|
||||
if (areq.getCredentials() instanceof BureauCredentials) {
|
||||
return PresentsClient.class;
|
||||
return PresentsSession.class;
|
||||
} else {
|
||||
return _delegate.getClientClass(areq);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ import com.threerings.presents.data.ClientObject;
|
||||
import com.threerings.presents.dobj.RootDObjectManager;
|
||||
import com.threerings.presents.server.ClientManager;
|
||||
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.BureauCodes;
|
||||
@@ -125,13 +125,13 @@ public class BureauRegistry
|
||||
public void init ()
|
||||
{
|
||||
_clmgr.addClientObserver(new ClientManager.ClientObserver() {
|
||||
public void clientSessionDidStart (PresentsClient client) {
|
||||
public void clientSessionDidStart (PresentsSession client) {
|
||||
String id = BureauCredentials.extractBureauId(client.getUsername());
|
||||
if (id != null) {
|
||||
sessionDidStart(client, id);
|
||||
}
|
||||
}
|
||||
public void clientSessionDidEnd (PresentsClient client) {
|
||||
public void clientSessionDidEnd (PresentsSession client) {
|
||||
String id = BureauCredentials.extractBureauId(client.getUsername());
|
||||
if (id != null) {
|
||||
sessionDidEnd(client, id);
|
||||
@@ -323,7 +323,7 @@ public class BureauRegistry
|
||||
/**
|
||||
* 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);
|
||||
if (bureau == null) {
|
||||
@@ -332,7 +332,7 @@ public class BureauRegistry
|
||||
return bureau.client;
|
||||
}
|
||||
|
||||
protected void sessionDidStart (PresentsClient client, String id)
|
||||
protected void sessionDidStart (PresentsSession client, String id)
|
||||
{
|
||||
Bureau bureau = _bureaus.get(id);
|
||||
if (bureau == null) {
|
||||
@@ -346,7 +346,7 @@ public class BureauRegistry
|
||||
bureau.client = client;
|
||||
}
|
||||
|
||||
protected void sessionDidEnd (PresentsClient client, String id)
|
||||
protected void sessionDidEnd (PresentsSession client, String id)
|
||||
{
|
||||
Bureau bureau = _bureaus.get(id);
|
||||
if (bureau == null) {
|
||||
@@ -691,7 +691,7 @@ public class BureauRegistry
|
||||
ClientObject clientObj;
|
||||
|
||||
// The client session
|
||||
PresentsClient client;
|
||||
PresentsSession client;
|
||||
|
||||
// The states of the various agents allocated to this bureau
|
||||
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.server.InvocationException;
|
||||
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.crowd.chat.client.ChatService;
|
||||
@@ -130,7 +130,7 @@ public class CrowdPeerManager extends PeerManager
|
||||
}
|
||||
|
||||
@Override // documentation inherited
|
||||
protected void initClientInfo (PresentsClient client, ClientInfo info)
|
||||
protected void initClientInfo (PresentsSession client, ClientInfo info)
|
||||
{
|
||||
super.initClientInfo(client, info);
|
||||
((CrowdClientInfo)info).visibleName =
|
||||
|
||||
@@ -45,8 +45,8 @@ public class CrowdObjectAccess
|
||||
// documentation inherited from interface
|
||||
public boolean allowSubscribe (DObject object, Subscriber<?> sub)
|
||||
{
|
||||
if (CrowdClient.class.isInstance(sub)) {
|
||||
ClientObject co = CrowdClient.class.cast(sub).getClientObject();
|
||||
if (CrowdSession.class.isInstance(sub)) {
|
||||
ClientObject co = CrowdSession.class.cast(sub).getClientObject();
|
||||
return ((PlaceObject)object).occupants.contains(co.getOid());
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -31,7 +31,7 @@ import com.threerings.util.Name;
|
||||
import com.threerings.presents.net.AuthRequest;
|
||||
import com.threerings.presents.server.ClientFactory;
|
||||
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.crowd.chat.server.ChatProvider;
|
||||
@@ -64,8 +64,8 @@ public class CrowdServer extends PresentsServer
|
||||
|
||||
// configure the client manager to use our bits
|
||||
_clmgr.setClientFactory(new ClientFactory() {
|
||||
public Class<? extends PresentsClient> getClientClass (AuthRequest areq) {
|
||||
return CrowdClient.class;
|
||||
public Class<? extends PresentsSession> getClientClass (AuthRequest areq) {
|
||||
return CrowdSession.class;
|
||||
}
|
||||
public Class<? extends ClientResolver> getClientResolverClass (Name username) {
|
||||
return CrowdClientResolver.class;
|
||||
|
||||
+3
-3
@@ -23,16 +23,16 @@ package com.threerings.crowd.server;
|
||||
|
||||
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.data.BodyObject;
|
||||
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
|
||||
protected void sessionConnectionClosed ()
|
||||
@@ -29,7 +29,7 @@ import com.threerings.presents.dobj.RootDObjectManager;
|
||||
import com.threerings.presents.server.ClientManager;
|
||||
import com.threerings.presents.server.InvocationException;
|
||||
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.data.BodyObject;
|
||||
@@ -111,7 +111,7 @@ public class LocationManager
|
||||
}
|
||||
|
||||
// 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) {
|
||||
client.setClassLoader(pmgr.getClass().getClassLoader());
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ package com.threerings.presents.net;
|
||||
public class AuthResponse extends DownstreamMessage
|
||||
{
|
||||
/** 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,
|
||||
* say, an authentication database into the runtime system to be used, for
|
||||
* example for permissions. */
|
||||
|
||||
@@ -27,7 +27,7 @@ import com.threerings.presents.net.AuthRequest;
|
||||
import com.threerings.presents.peer.net.PeerCreds;
|
||||
import com.threerings.presents.server.ClientFactory;
|
||||
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
|
||||
@@ -41,10 +41,10 @@ public class PeerClientFactory implements 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) {
|
||||
return PeerClient.class;
|
||||
return PeerSession.class;
|
||||
} else {
|
||||
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.InvocationException;
|
||||
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.ReportManager;
|
||||
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)
|
||||
{
|
||||
@@ -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)
|
||||
{
|
||||
@@ -768,7 +768,7 @@ public abstract class PeerManager
|
||||
}
|
||||
|
||||
// from interface ClientManager.ClientObserver
|
||||
public void clientSessionDidStart (PresentsClient client)
|
||||
public void clientSessionDidStart (PresentsSession client)
|
||||
{
|
||||
if (ignoreClient(client)) {
|
||||
return;
|
||||
@@ -790,7 +790,7 @@ public abstract class PeerManager
|
||||
}
|
||||
|
||||
// from interface ClientManager.ClientObserver
|
||||
public void clientSessionDidEnd (PresentsClient client)
|
||||
public void clientSessionDidEnd (PresentsSession client)
|
||||
{
|
||||
if (ignoreClient(client)) {
|
||||
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
|
||||
* both times.
|
||||
*/
|
||||
protected boolean ignoreClient (PresentsClient client)
|
||||
protected boolean ignoreClient (PresentsSession client)
|
||||
{
|
||||
// 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.
|
||||
*/
|
||||
protected void initClientInfo (PresentsClient client, ClientInfo info)
|
||||
protected void initClientInfo (PresentsSession client, ClientInfo info)
|
||||
{
|
||||
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.
|
||||
*/
|
||||
protected void clearClientInfo (PresentsClient client, ClientInfo info)
|
||||
protected void clearClientInfo (PresentsSession client, ClientInfo info)
|
||||
{
|
||||
_nodeobj.removeFromClients(info.getKey());
|
||||
}
|
||||
|
||||
+17
-20
@@ -29,28 +29,27 @@ import com.threerings.presents.dobj.DObject;
|
||||
import com.threerings.presents.net.BootstrapData;
|
||||
import com.threerings.presents.peer.data.NodeObject;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* manager. This is only done by the {@link PeerClientFactory}.
|
||||
* Creates a peer session and provides it with a reference to the peer manager. This is only
|
||||
* done by the {@link PeerClientFactory}.
|
||||
*/
|
||||
@Inject public PeerClient (PeerManager peermgr)
|
||||
@Inject public PeerSession (PeerManager peermgr)
|
||||
{
|
||||
_peermgr = peermgr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Derived client classes can override this member to create derived
|
||||
* bootstrap data classes that contain extra bootstrap information, if
|
||||
* desired.
|
||||
* Derived classes can override this member to create derived bootstrap data classes that
|
||||
* contain extra bootstrap information, if desired.
|
||||
*/
|
||||
@Override
|
||||
protected BootstrapData createBootstrapData ()
|
||||
@@ -59,14 +58,12 @@ public class PeerClient extends PresentsClient
|
||||
}
|
||||
|
||||
/**
|
||||
* Derived client classes can override this member to populate the
|
||||
* bootstrap data with additional information. They should be sure to
|
||||
* call <code>super.populateBootstrapData</code> before doing their
|
||||
* own populating, however.
|
||||
* Derived classes can override this member to populate the bootstrap data with additional
|
||||
* information. They should be sure to call <code>super.populateBootstrapData</code> before
|
||||
* doing their own populating, however.
|
||||
*
|
||||
* <p><em>Note:</em> This function will be called on the dobjmgr
|
||||
* thread which means that object manipulations are OK, but client
|
||||
* instance manipulations must be done carefully.
|
||||
* <p><em>Note:</em> This function will be called on the dobjmgr thread which means that object
|
||||
* manipulations are OK, but client instance manipulations must be done carefully.
|
||||
*/
|
||||
@Override
|
||||
protected void populateBootstrapData (BootstrapData data)
|
||||
@@ -87,7 +84,7 @@ public class PeerClient extends PresentsClient
|
||||
_cloid = _clobj.getOid();
|
||||
}
|
||||
|
||||
@Override // from PresentsClient
|
||||
@Override // from PresentsSession
|
||||
protected void subscribedToObject (DObject object)
|
||||
{
|
||||
super.subscribedToObject(object);
|
||||
@@ -96,7 +93,7 @@ public class PeerClient extends PresentsClient
|
||||
}
|
||||
}
|
||||
|
||||
@Override // from PresentsClient
|
||||
@Override // from PresentsSession
|
||||
protected void unsubscribedFromObject (DObject object)
|
||||
{
|
||||
super.unsubscribedFromObject(object);
|
||||
@@ -105,14 +102,14 @@ public class PeerClient extends PresentsClient
|
||||
}
|
||||
}
|
||||
|
||||
@Override // from PresentsClient
|
||||
@Override // from PresentsSession
|
||||
protected Throttle createIncomingMessageThrottle ()
|
||||
{
|
||||
// more than 100 messages per second and we complain about it
|
||||
return new Throttle(100, 1000L);
|
||||
}
|
||||
|
||||
@Override // from PresentsClient
|
||||
@Override // from PresentsSession
|
||||
protected void handleThrottleExceeded ()
|
||||
{
|
||||
long now = System.currentTimeMillis();
|
||||
@@ -26,15 +26,15 @@ import com.threerings.util.Name;
|
||||
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.
|
||||
*/
|
||||
public interface ClientFactory
|
||||
{
|
||||
/** The default client factory. */
|
||||
public static ClientFactory DEFAULT = new ClientFactory() {
|
||||
public Class<? extends PresentsClient> getClientClass (AuthRequest areq) {
|
||||
return PresentsClient.class;
|
||||
public Class<? extends PresentsSession> getClientClass (AuthRequest areq) {
|
||||
return PresentsSession.class;
|
||||
}
|
||||
public Class<? extends ClientResolver> getClientResolverClass (Name username) {
|
||||
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.
|
||||
*/
|
||||
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
|
||||
|
||||
@@ -88,13 +88,13 @@ public class ClientManager
|
||||
/**
|
||||
* 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
|
||||
* 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.
|
||||
*/
|
||||
public void setInjector (Injector injector)
|
||||
@@ -134,7 +134,7 @@ public class ClientManager
|
||||
|
||||
// inform all of our clients that they are being shut down
|
||||
synchronized (_usermap) {
|
||||
for (PresentsClient pc : _usermap.values()) {
|
||||
for (PresentsSession pc : _usermap.values()) {
|
||||
try {
|
||||
pc.shutdown();
|
||||
} 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.
|
||||
*/
|
||||
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
|
||||
* 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) {
|
||||
return _usermap.get(authUsername);
|
||||
@@ -375,7 +375,7 @@ public class ClientManager
|
||||
Name username = creds.getUsername();
|
||||
|
||||
// see if a client is already registered with these credentials
|
||||
PresentsClient client = getClient(username);
|
||||
PresentsSession client = getClient(username);
|
||||
|
||||
if (client != null) {
|
||||
log.info("Resuming session [username=" + username + ", conn=" + conn + "].");
|
||||
@@ -401,7 +401,7 @@ public class ClientManager
|
||||
public synchronized void connectionFailed (Connection conn, IOException fault)
|
||||
{
|
||||
// remove the client from the connection map
|
||||
PresentsClient client = _conmap.remove(conn);
|
||||
PresentsSession client = _conmap.remove(conn);
|
||||
if (client != null) {
|
||||
log.info("Unmapped failed client [client=" + client + ", conn=" + conn +
|
||||
", fault=" + fault + "].");
|
||||
@@ -419,7 +419,7 @@ public class ClientManager
|
||||
public synchronized void connectionClosed (Connection conn)
|
||||
{
|
||||
// remove the client from the connection map
|
||||
PresentsClient client = _conmap.remove(conn);
|
||||
PresentsSession client = _conmap.remove(conn);
|
||||
if (client != null) {
|
||||
log.debug("Unmapped client [client=" + client + ", conn=" + conn + "].");
|
||||
// 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
|
||||
* dobjmgr thread.
|
||||
*/
|
||||
protected void clientSessionDidStart (final PresentsClient client)
|
||||
protected void clientSessionDidStart (final PresentsSession client)
|
||||
{
|
||||
// let the observers know
|
||||
_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
|
||||
* dobjmgr thread.
|
||||
*/
|
||||
protected void clientSessionDidEnd (final PresentsClient client)
|
||||
protected void clientSessionDidEnd (final PresentsSession client)
|
||||
{
|
||||
// remove the client from the username map
|
||||
Name username = client.getCredentials().getUsername();
|
||||
PresentsClient rc;
|
||||
PresentsSession rc;
|
||||
synchronized (_usermap) {
|
||||
rc = _usermap.remove(username);
|
||||
}
|
||||
@@ -497,12 +497,12 @@ public class ClientManager
|
||||
*/
|
||||
protected void flushClients ()
|
||||
{
|
||||
List<PresentsClient> victims = Lists.newArrayList();
|
||||
List<PresentsSession> victims = Lists.newArrayList();
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
// first build a list of our victims
|
||||
synchronized (_usermap) {
|
||||
for (PresentsClient client : _usermap.values()) {
|
||||
for (PresentsSession client : _usermap.values()) {
|
||||
if (client.checkExpired(now)) {
|
||||
victims.add(client);
|
||||
}
|
||||
@@ -510,7 +510,7 @@ public class ClientManager
|
||||
}
|
||||
|
||||
// now end their sessions
|
||||
for (PresentsClient client : victims) {
|
||||
for (PresentsSession client : victims) {
|
||||
try {
|
||||
log.info("Client expired, ending session [client=" + client +
|
||||
", dtime=" + (now-client.getNetworkStamp()) + "ms].");
|
||||
@@ -549,14 +549,14 @@ public class ClientManager
|
||||
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;
|
||||
|
||||
/** 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. */
|
||||
protected Map<Connection, PresentsClient> _conmap = Maps.newHashMap();
|
||||
protected Map<Connection, PresentsSession> _conmap = Maps.newHashMap();
|
||||
|
||||
/** A mapping from usernames to client object instances. */
|
||||
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
|
||||
* {@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 ()
|
||||
{
|
||||
|
||||
@@ -74,8 +74,8 @@ public class PresentsObjectAccess
|
||||
{
|
||||
boolean allowed = true;
|
||||
// if the subscriber is a client, ensure that they are this same user
|
||||
if (PresentsClient.class.isInstance(sub)) {
|
||||
PresentsClient client = PresentsClient.class.cast(sub);
|
||||
if (PresentsSession.class.isInstance(sub)) {
|
||||
PresentsSession client = PresentsSession.class.cast(sub);
|
||||
allowed = (client.getClientObject() == object);
|
||||
if (!allowed) {
|
||||
log.warning("Refusing ClientObject subscription request " +
|
||||
|
||||
+14
-14
@@ -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
|
||||
* from the conmgr thread and therefore also need not be synchronized.
|
||||
*/
|
||||
public class PresentsClient
|
||||
public class PresentsSession
|
||||
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
|
||||
{
|
||||
/** 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 ()
|
||||
{
|
||||
@@ -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 ()
|
||||
{
|
||||
@@ -122,8 +122,8 @@ public class PresentsClient
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this client has been disconnected for sufficiently long that its session
|
||||
* should be forcibly ended.
|
||||
* Returns true if this session has been disconnected for sufficiently long that it should be
|
||||
* forcibly ended.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
public void setClassLoader (ClassLoader loader)
|
||||
@@ -966,7 +966,7 @@ public class PresentsClient
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
public void dispatch (PresentsClient client, UpstreamMessage msg)
|
||||
public void dispatch (PresentsSession client, UpstreamMessage msg)
|
||||
{
|
||||
SubscribeRequest req = (SubscribeRequest)msg;
|
||||
// log.info("Subscribing [client=" + client + ", oid=" + req.getOid() + "].");
|
||||
@@ -989,7 +989,7 @@ public class PresentsClient
|
||||
*/
|
||||
protected static class UnsubscribeDispatcher implements MessageDispatcher
|
||||
{
|
||||
public void dispatch (PresentsClient client, UpstreamMessage msg)
|
||||
public void dispatch (PresentsSession client, UpstreamMessage msg)
|
||||
{
|
||||
UnsubscribeRequest req = (UnsubscribeRequest)msg;
|
||||
int oid = req.getOid();
|
||||
@@ -1009,7 +1009,7 @@ public class PresentsClient
|
||||
*/
|
||||
protected static class ForwardEventDispatcher implements MessageDispatcher
|
||||
{
|
||||
public void dispatch (PresentsClient client, UpstreamMessage msg)
|
||||
public void dispatch (PresentsSession client, UpstreamMessage msg)
|
||||
{
|
||||
ForwardEventRequest req = (ForwardEventRequest)msg;
|
||||
DEvent fevt = req.getEvent();
|
||||
@@ -1036,7 +1036,7 @@ public class PresentsClient
|
||||
*/
|
||||
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
|
||||
PingRequest req = (PingRequest)msg;
|
||||
@@ -1049,7 +1049,7 @@ public class PresentsClient
|
||||
*/
|
||||
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);
|
||||
client.throttleUpdated();
|
||||
@@ -1061,7 +1061,7 @@ public class PresentsClient
|
||||
*/
|
||||
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);
|
||||
client.safeEndSession();
|
||||
@@ -32,7 +32,7 @@ import com.google.inject.Injector;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
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.bureau.data.AgentObject;
|
||||
@@ -199,7 +199,7 @@ public class RegistryTester
|
||||
{
|
||||
if (_rng1.nextInt(100) < _killBureauChance) {
|
||||
log.info("Killing a bureau");
|
||||
PresentsClient bureau = getRandomBureau();
|
||||
PresentsSession bureau = getRandomBureau();
|
||||
if (bureau == null) {
|
||||
log.info("No bureaus to kill right now");
|
||||
return;
|
||||
@@ -221,7 +221,7 @@ public class RegistryTester
|
||||
}
|
||||
}
|
||||
|
||||
protected PresentsClient getRandomBureau ()
|
||||
protected PresentsSession getRandomBureau ()
|
||||
{
|
||||
boolean[] tried = new boolean[_numBureaus];
|
||||
for (int dead = 0; dead < _numBureaus;) {
|
||||
@@ -230,7 +230,7 @@ public class RegistryTester
|
||||
continue;
|
||||
}
|
||||
String id = "test-" + (index + 1);
|
||||
PresentsClient client = _bureauReg.lookupClient(id);
|
||||
PresentsSession client = _bureauReg.lookupClient(id);
|
||||
if (client == null) {
|
||||
++dead;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user