public class ClientManager extends Object implements ClientResolutionListener, ReportManager.Reporter, Lifecycle.Component
The client manager operates with thread safety because it is called both from the conmgr thread (to notify of connections showing up or going away) and from the dobjmgr thread (when clients are given the boot for application-defined reasons).
| Modifier and Type | Class and Description |
|---|---|
static interface |
ClientManager.ClientObserver
Used by entities that wish to track when clients initiate and end sessions on this server.
|
static interface |
ClientManager.ClientOp
|
static interface |
ClientManager.DetailedClientObserver
Methods for observing additional events in the session lifecycle.
|
| Constructor and Description |
|---|
ClientManager(ReportManager repmgr,
Lifecycle cycle)
Constructs a client manager that will interact with the supplied connection manager.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addClientObserver(ClientManager.ClientObserver observer)
Registers an observer that will be notified when clients start and end their sessions.
|
void |
addSessionFactory(SessionFactory factory)
Adds a session factory to the chain.
|
void |
appendReport(StringBuilder report,
long now,
long sinceLast,
boolean reset)
Requests that this reporter append its report to the supplied string buffer.
|
void |
applyToClient(Name username,
ClientManager.ClientOp clop)
Resolves the specified client, applies the supplied client operation to them and releases
the client.
|
Iterable<ClientObject> |
clientObjects()
Returns an iterable over all active client objects.
|
void |
clientResolved(Name username,
ClientObject clobj)
Called when resolution completed successfully.
|
void |
connectionClosed(Connection conn)
Called by the connection manager to let us know when a connection has been closed.
|
void |
connectionEstablished(PresentsConnection conn,
Name authname,
AuthRequest req,
AuthResponse rsp)
Called by the connection manager to let us know when a new connection has been established.
|
void |
connectionFailed(Connection conn,
IOException fault)
Called by the connection manager to let us know when a connection has failed.
|
Iterator<ClientObject> |
enumerateClientObjects()
Enumerates all active client objects.
|
PresentsSession |
getClient(Name authUsername)
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.
|
int |
getClientCount()
Returns the number of client sessions (some may be disconnected).
|
ClientObject |
getClientObject(Name username)
Returns the client object associated with the specified username.
|
int |
getConnectionCount()
Returns the number of connected clients.
|
int |
getOutstandingResolutionCount()
Return the number of client resolutions are currently happening.
|
List<PresentsSession> |
getSessionsForAddress(byte[] addr)
Returns all sessions logged in from the given IP in the form returned from
InetAddress.getAddress(). |
void |
init() |
void |
releaseClientObject(Name username)
Releases a client object that was obtained via a call to
resolveClientObject(com.threerings.util.Name, com.threerings.presents.server.ClientResolutionListener). |
void |
removeClientObserver(ClientManager.ClientObserver observer)
Removes an observer previously registered with
addClientObserver(com.threerings.presents.server.ClientManager.ClientObserver). |
void |
resolutionFailed(Name username,
Exception reason)
Called when resolution fails.
|
void |
resolveClientObject(Name username,
ClientResolutionListener listener)
Requests that the client object for the specified user be resolved.
|
void |
setDefaultSessionFactory(SessionFactory factory)
Configures the default factory for creating
PresentsSession and ClientResolver classes for authenticated client connections. |
void |
setInjector(com.google.inject.Injector injector)
Configures the injector we'll use to resolve dependencies for
PresentsSession
instances. |
void |
shutdown() |
@Inject public ClientManager(ReportManager repmgr, Lifecycle cycle)
public void setInjector(com.google.inject.Injector injector)
PresentsSession
instances.public void setDefaultSessionFactory(SessionFactory factory)
PresentsSession and ClientResolver classes for authenticated client connections. All factories added via addSessionFactory(com.threerings.presents.server.SessionFactory) will be offered a chance to handle sessions before this factory of last
resort.public void addSessionFactory(SessionFactory factory)
public int getOutstandingResolutionCount()
public int getClientCount()
public List<PresentsSession> getSessionsForAddress(byte[] addr)
InetAddress.getAddress().public int getConnectionCount()
public Iterable<ClientObject> clientObjects()
public Iterator<ClientObject> enumerateClientObjects()
public void addClientObserver(ClientManager.ClientObserver observer)
public void removeClientObserver(ClientManager.ClientObserver observer)
addClientObserver(com.threerings.presents.server.ClientManager.ClientObserver).public PresentsSession getClient(Name authUsername)
public ClientObject getClientObject(Name username)
public void applyToClient(Name username, ClientManager.ClientOp clop)
public void resolveClientObject(Name username, ClientResolutionListener listener)
releaseClientObject(com.threerings.util.Name) when the caller is
finished with the client object.public void releaseClientObject(Name username)
resolveClientObject(com.threerings.util.Name, com.threerings.presents.server.ClientResolutionListener). If
this caller is the last reference, the object will be flushed and destroyed.public void init()
init in interface Lifecycle.InitComponentpublic void shutdown()
shutdown in interface Lifecycle.ShutdownComponentpublic void clientResolved(Name username, ClientObject clobj)
ClientResolutionListenerclientResolved in interface ClientResolutionListenerpublic void resolutionFailed(Name username, Exception reason)
ClientResolutionListenerresolutionFailed in interface ClientResolutionListenerpublic void connectionEstablished(PresentsConnection conn, Name authname, AuthRequest req, AuthResponse rsp)
public void connectionFailed(Connection conn, IOException fault)
public void connectionClosed(Connection conn)
public void appendReport(StringBuilder report, long now, long sinceLast, boolean reset)
ReportManager.ReporterappendReport in interface ReportManager.Reporterreport - the string buffer to which the report text should be appended.now - the time at which the report generation began, in epoch millis.sinceLast - number of milliseconds since the last time we generated a report.reset - if true, all accumulating stats should be reset, if false they should be
allowed to continue to accumulate.Copyright © 2015. All rights reserved.