public class PresentsSession extends Object implements PresentsConnection.MessageHandler, ClientResolutionListener
A note on synchronization: the client object is structured so that its
Subscriber implementation (which is called from the dobjmgr thread) can proceed
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.
| Modifier and Type | Class and Description |
|---|---|
static interface |
PresentsSession.UserChangeListener
Used by
setUsername(com.threerings.util.Name, com.threerings.presents.server.PresentsSession.UserChangeListener) to report success or failure. |
| Constructor and Description |
|---|
PresentsSession() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
checkExpired(long now)
Returns true if this session has been disconnected for sufficiently long that it should be
forcibly ended.
|
void |
clientResolved(Name username,
ClientObject clobj)
Called when resolution completed successfully.
|
void |
endSession()
Forcibly terminates a client's session.
|
Name |
getAuthName()
Returns the username with which this client authenticated.
|
ClientObject |
getClientObject()
returns the client object that is associated with this client.
|
Credentials |
getCredentials()
Returns the credentials used to authenticate this session.
|
InetAddress |
getInetAddress()
Returns the address of the connected client or null if this client is not connected.
|
long |
getNetworkStamp()
Returns the time at which this client most recently connected or disconnected.
|
byte[] |
getSecret()
Returns the shared secret for this session.
|
long |
getSessionStamp()
Returns the time at which this client started their network session.
|
TimeZone |
getTimeZone()
Returns the time zone in which the client is operating.
|
boolean |
getTransmitDatagrams()
Checks whether the client has requested that datagram transmission be enabled.
|
void |
handleMessage(Message message)
Called when a complete message has been parsed from incoming network data.
|
void |
resolutionFailed(Name username,
Exception reason)
Called when resolution fails.
|
void |
setClassLoader(ClassLoader loader)
Configures this session with a custom class loader that will be used when unserializing
classes from the network.
|
void |
setIncomingMessageThrottle(int messagesPerSec)
Configures the rate at which incoming messages are throttled for this client.
|
void |
setUsername(Name username,
PresentsSession.UserChangeListener ucl)
Danger: this method is not for general consumption.
|
void |
shutdown()
This is called when the server is shut down in the middle of a client session.
|
String |
toString() |
boolean |
updateUsername(Name username)
Double Danger: this method is not for general consumption.
|
public Credentials getCredentials()
public TimeZone getTimeZone()
public byte[] getSecret()
public boolean checkExpired(long now)
public long getSessionStamp()
public long getNetworkStamp()
public Name getAuthName()
setUsername(com.threerings.util.Name, com.threerings.presents.server.PresentsSession.UserChangeListener) has
been called this may differ from getClientObject().username.public InetAddress getInetAddress()
public boolean getTransmitDatagrams()
public void setClassLoader(ClassLoader loader)
public void setIncomingMessageThrottle(int messagesPerSec)
Note: this means that a hacked client can refuse to ACK message rate reductions and continue to use the most generous rate ever assigned to it. Don't increase the throttle beyond the default for untrusted clients. This mechanism exists so that trusted clients can have their throttle relaxed in a robust manner which will not result in disconnects if the client happens to be at or near the throttle limit when the throttle is reduced.
public void setUsername(Name username, PresentsSession.UserChangeListener ucl)
It exists to support systems wherein a user logs in with an account username and then chooses a "screen name" by which they will play (often from a small set of available "characters" available per account). This will take care of remapping the username to client object mappings that were made by the Presents services when the user logs on, but anything else that has had its grubby mits on the username will be left to its own devices, hence the care that must be exercised when using this method.
ucl - an entity that will (optionally) be notified when the username conversion process
is complete.public boolean updateUsername(Name username)
#setUsername, this changes the username of the client, but unlike setUsername, it
does it in the existing client object. Care must be taken to ensure that any client or
server code either doesn't map things based on username before this call, or that it's
updated to reflect the change.public ClientObject getClientObject()
public void endSession()
public void shutdown()
endSession() will not be called and so any persistent data
that might normally be flushed at the end of a client's session should likely be flushed
here.public void clientResolved(Name username, ClientObject clobj)
ClientResolutionListenerclientResolved in interface ClientResolutionListenerpublic void resolutionFailed(Name username, Exception reason)
ClientResolutionListenerresolutionFailed in interface ClientResolutionListenerpublic void handleMessage(Message message)
PresentsConnection.MessageHandlerhandleMessage in interface PresentsConnection.MessageHandlerCopyright © 2015. All rights reserved.