com.threerings.presents.peer.server
Class PeerSession

java.lang.Object
  extended by com.threerings.presents.server.PresentsSession
      extended by com.threerings.presents.peer.server.PeerSession
All Implemented Interfaces:
ClientResolutionListener, PresentsConnection.MessageHandler

public class PeerSession
extends PresentsSession

Manages a peer session.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.threerings.presents.server.PresentsSession
PresentsSession.ClientProxy, PresentsSession.CompoundDispatcher, PresentsSession.ForwardEventDispatcher, PresentsSession.LogoffDispatcher, PresentsSession.MessageDispatcher, PresentsSession.PingDispatcher, PresentsSession.SubscribeDispatcher, PresentsSession.ThrottleUpdatedDispatcher, PresentsSession.TransmitDatagramsDispatcher, PresentsSession.UnsubscribeDispatcher, PresentsSession.UserChangeListener
 
Field Summary
protected  int _cloid
           
protected  long _nextThrottleWarning
           
protected  PeerManager _peermgr
           
protected  PeerManager.Stats _stats
           
 
Fields inherited from class com.threerings.presents.server.PresentsSession
_areq, _authdata, _authname, _clmgr, _clobj, _compound, _compoundDepth, _conmgr, _conn, _connectTime, _destroyedSubs, _disps, _invmgr, _loader, _messagesDropped, _messagesIn, _messagesOut, _messagesPerSec, _networkStamp, _omgr, _pendingThrottles, _sessionStamp, _subscrips, _throttle, DEFAULT_FLUSH_TIME, PING_DEBUG
 
Constructor Summary
PeerSession(PeerManager peermgr)
          Creates a peer session and provides it with a reference to the peer manager.
 
Method Summary
protected  BootstrapData createBootstrapData()
          Derived client classes can override this member to create derived bootstrap data classes that contain extra bootstrap information, if desired.
protected  Throttle createIncomingMessageThrottle()
          Creates our incoming message throttle.
 void handleMessage(Message message)
          Called when a complete message has been parsed from incoming network data.
protected  void handleThrottleExceeded()
          Called when a client exceeds their allotted incoming messages per second throttle.
protected  void populateBootstrapData(BootstrapData data)
          Derived client classes can override this member to populate the bootstrap data with additional information.
protected  boolean postMessage(DownstreamMessage msg, PresentsConnection expect)
          Queues a message for delivery to the client.
protected  void sessionConnectionClosed()
          Called on the dobjmgr thread when the connection associated with this session has been closed and unmapped.
protected  void sessionDidEnd()
          Called when the client session ends (either because the client logged off or because the server forcibly terminated the session).
protected  void sessionWillStart()
          Called when the client session is first started.
 void setStats(PeerManager.Stats stats)
          Passes in a stats instance that this peer can use to note when it trafficks.
protected  void subscribedToObject(DObject object)
          Called to inform derived classes when the client has subscribed to a distributed object.
protected  void unsubscribedFromObject(DObject object)
          Called to inform derived classes when the client has unsubscribed from a distributed object.
 
Methods inherited from class com.threerings.presents.server.PresentsSession
checkExpired, clearSubscrips, clientObjectDidChange, clientObjectWillChange, clientResolved, connectionFailed, createProxySubscriber, dispatchMessage, endSession, finishCompoundMessage, finishResumeSession, getAuthName, getClientObject, getConnection, getCredentials, getFlushTime, getInetAddress, getNetworkStamp, getSecret, getSessionStamp, getTimeZone, getTransmitDatagrams, resolutionFailed, resumeSession, safeEndSession, safePostMessage, safePostMessage, sendBootstrap, sendThrottleUpdate, sessionWillResume, setClassLoader, setConnection, setIncomingMessageThrottle, setUsername, shutdown, startCompoundMessage, startSession, throttleUpdated, toString, toString, unmapSubscrip, updateUsername, wasUnmapped, who
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_peermgr

protected PeerManager _peermgr

_stats

protected PeerManager.Stats _stats

_cloid

protected int _cloid

_nextThrottleWarning

protected long _nextThrottleWarning
Constructor Detail

PeerSession

@Inject
public PeerSession(PeerManager peermgr)
Creates a peer session and provides it with a reference to the peer manager.

Method Detail

setStats

public void setStats(PeerManager.Stats stats)
Passes in a stats instance that this peer can use to note when it trafficks.


handleMessage

public void handleMessage(Message message)
Description copied from interface: PresentsConnection.MessageHandler
Called when a complete message has been parsed from incoming network data.

Specified by:
handleMessage in interface PresentsConnection.MessageHandler
Overrides:
handleMessage in class PresentsSession

createBootstrapData

protected BootstrapData createBootstrapData()
Description copied from class: PresentsSession
Derived client classes can override this member to create derived bootstrap data classes that contain extra bootstrap information, if desired.

Overrides:
createBootstrapData in class PresentsSession

populateBootstrapData

protected void populateBootstrapData(BootstrapData data)
Description copied from class: PresentsSession
Derived client classes can override this member to populate the bootstrap data with additional information. They should be sure to call super.populateBootstrapData before doing their own populating, however.

Note: This function will be called on the dobjmgr thread which means that object manipulations are OK, but client instance manipulations must be done carefully.

Overrides:
populateBootstrapData in class PresentsSession

sessionWillStart

protected void sessionWillStart()
Description copied from class: PresentsSession
Called when the client session is first started. The client object has been created at this point and after this method is executed, the bootstrap information will be sent to the client which will trigger the start of the session. Derived classes that override this method should be sure to call super.sessionWillStart.

Note: This function will be called on the dobjmgr thread which means that object manipulations are OK, but client instance manipulations must done carefully.

Overrides:
sessionWillStart in class PresentsSession

sessionConnectionClosed

protected void sessionConnectionClosed()
Description copied from class: PresentsSession
Called on the dobjmgr thread when the connection associated with this session has been closed and unmapped. If the user logged off before closing their connection, this will be preceded by a call to PresentsSession.sessionDidEnd().

Overrides:
sessionConnectionClosed in class PresentsSession

sessionDidEnd

protected void sessionDidEnd()
Description copied from class: PresentsSession
Called when the client session ends (either because the client logged off or because the server forcibly terminated the session). Derived classes that override this method should be sure to call super.sessionDidEnd.

Note: This function will be called on the dobjmgr thread which means that object manipulations are OK, but client instance manipulations must done carefully.

Overrides:
sessionDidEnd in class PresentsSession

postMessage

protected final boolean postMessage(DownstreamMessage msg,
                                    PresentsConnection expect)
Description copied from class: PresentsSession
Queues a message for delivery to the client.

Overrides:
postMessage in class PresentsSession

subscribedToObject

protected void subscribedToObject(DObject object)
Description copied from class: PresentsSession
Called to inform derived classes when the client has subscribed to a distributed object.

Overrides:
subscribedToObject in class PresentsSession

unsubscribedFromObject

protected void unsubscribedFromObject(DObject object)
Description copied from class: PresentsSession
Called to inform derived classes when the client has unsubscribed from a distributed object.

Overrides:
unsubscribedFromObject in class PresentsSession

createIncomingMessageThrottle

protected Throttle createIncomingMessageThrottle()
Description copied from class: PresentsSession
Creates our incoming message throttle. Use PresentsSession.setIncomingMessageThrottle(int) to adjust the throttle for running clients.

Overrides:
createIncomingMessageThrottle in class PresentsSession

handleThrottleExceeded

protected void handleThrottleExceeded()
Description copied from class: PresentsSession
Called when a client exceeds their allotted incoming messages per second throttle.

Overrides:
handleThrottleExceeded in class PresentsSession