com.threerings.presents.client
Class Communicator

java.lang.Object
  extended by com.threerings.presents.client.Communicator
Direct Known Subclasses:
BlockingCommunicator, ServerCommunicator

public abstract class Communicator
extends Object

Handles sending and receiving messages for the client.


Field Summary
protected  Client _client
           
protected  long _lastWrite
           
protected  ClientDObjectMgr _omgr
           
 
Constructor Summary
Communicator(Client client)
          Creates a new communicator instance which is associated with the supplied client.
 
Method Summary
protected  void clientCleanup(Exception logonError)
           
 long getLastWrite()
          Returns the time at which we last sent a packet to the server.
 boolean getTransmitDatagrams()
          Checks whether we should transmit datagrams.
protected  void gotAuthResponse(AuthResponse rsp)
          Subclasses must call this method when they receive the authentication response.
abstract  void gotBootstrap()
          Notifies the communicator that the client has received its bootstrap data.
abstract  void logoff()
          Delivers a logoff notification to the server and shuts down the network connection.
abstract  void logon()
          Logs on to the server and initiates our full-duplex message exchange.
protected  void logonSucceeded(AuthResponseData data)
          Called when the authentication process completes successfully.
protected  void notifyClientObservers(ObserverOps.Session op)
           
abstract  void postMessage(UpstreamMessage msg)
          Queues up the specified message for delivery upstream.
protected  void processMessage(Message msg)
          Callback called by the reader thread when it has parsed a new message from the socket and wishes to have it processed.
abstract  void setClassLoader(ClassLoader loader)
          Configures this communicator with a custom class loader to be used when reading and writing objects over the network.
protected  void updateWriteStamp()
          Makes a note of the time at which we last communicated with the server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_client

protected Client _client

_omgr

protected ClientDObjectMgr _omgr

_lastWrite

protected long _lastWrite
Constructor Detail

Communicator

public Communicator(Client client)
Creates a new communicator instance which is associated with the supplied client.

Method Detail

logon

public abstract void logon()
Logs on to the server and initiates our full-duplex message exchange.


logoff

public abstract void logoff()
Delivers a logoff notification to the server and shuts down the network connection. Also causes all communication threads to terminate.


gotBootstrap

public abstract void gotBootstrap()
Notifies the communicator that the client has received its bootstrap data.


postMessage

public abstract void postMessage(UpstreamMessage msg)
Queues up the specified message for delivery upstream.


setClassLoader

public abstract void setClassLoader(ClassLoader loader)
Configures this communicator with a custom class loader to be used when reading and writing objects over the network.


getLastWrite

public long getLastWrite()
Returns the time at which we last sent a packet to the server.


getTransmitDatagrams

public boolean getTransmitDatagrams()
Checks whether we should transmit datagrams.


updateWriteStamp

protected void updateWriteStamp()
Makes a note of the time at which we last communicated with the server.


gotAuthResponse

protected void gotAuthResponse(AuthResponse rsp)
                        throws LogonException
Subclasses must call this method when they receive the authentication response.

Throws:
LogonException

logonSucceeded

protected void logonSucceeded(AuthResponseData data)
Called when the authentication process completes successfully. Derived classes can override this method and complete any initialization that need wait for authentication success.


processMessage

protected void processMessage(Message msg)
Callback called by the reader thread when it has parsed a new message from the socket and wishes to have it processed.


notifyClientObservers

protected void notifyClientObservers(ObserverOps.Session op)

clientCleanup

protected void clientCleanup(Exception logonError)