com.threerings.presents.client
Class BasicDirector

java.lang.Object
  extended by com.threerings.presents.client.BasicDirector
All Implemented Interfaces:
SessionObserver
Direct Known Subclasses:
BureauDirector, ChatDirector, LocationDirector, MuteDirector, OccupantDirector

public class BasicDirector
extends Object
implements SessionObserver

Handles functionality common to nearly all client directors. They generally need to be session observers so that they can set themselves up when the client logs on (by overriding clientDidLogon(com.threerings.presents.client.Client)) and clean up after themselves when the client logs off (by overriding clientDidLogoff(com.threerings.presents.client.Client)).


Field Summary
protected  boolean _availableInStandalone
          Whether or not this director is available in standalone mode.
protected  PresentsContext _ctx
          The application context.
 
Constructor Summary
protected BasicDirector(PresentsContext ctx)
          Derived directors will need to provide the basic director with a context that it can use to register itself with the necessary entities.
 
Method Summary
protected  void assertAvailable()
          If this director is not currently available, throws a RuntimeException.
 void clientDidLogoff(Client client)
          Called after the client has been logged off of the server and has disconnected.
 void clientDidLogon(Client client)
          Called after the client successfully connected to and authenticated with the server.
 void clientObjectDidChange(Client client)
          For systems that allow switching screen names after logon, this method is called whenever a screen name change takes place to report that the client object has been replaced to potential client-side subscribers.
protected  void clientObjectUpdated(Client client)
          Called in three circumstances: when a director is created and we've already logged on; when we first log on and when the client object changes after we've already logged on.
 void clientWillLogon(Client client)
          Called immediately before a logon is attempted.
protected  void fetchServices(Client client)
          Derived directors can override this method and obtain any services they'll need during their operation via calls to Client.getService(java.lang.Class).
protected  boolean isAvailable()
          Checks whether this director is available in the current mode.
 boolean isAvailableInStandalone()
          Checks whether or not this director is available in standalone mode (defaults to false).
protected  void registerServices(Client client)
          If a director makes use of bootstrap invocation services which are part of a bootstrap service group, it should register interest in that group here with a call to Client.addServiceGroup(java.lang.String).
 void setAvailableInStandalone(boolean available)
          Sets whether or not this director is available in standalone mode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_ctx

protected PresentsContext _ctx
The application context.


_availableInStandalone

protected boolean _availableInStandalone
Whether or not this director is available in standalone mode.

Constructor Detail

BasicDirector

protected BasicDirector(PresentsContext ctx)
Derived directors will need to provide the basic director with a context that it can use to register itself with the necessary entities.

Method Detail

clientWillLogon

public void clientWillLogon(Client client)
Description copied from interface: SessionObserver
Called immediately before a logon is attempted.

Specified by:
clientWillLogon in interface SessionObserver

clientDidLogon

public void clientDidLogon(Client client)
Description copied from interface: SessionObserver
Called after the client successfully connected to and authenticated with the server. The entire object system is up and running by the time this method is called.

Specified by:
clientDidLogon in interface SessionObserver

clientObjectDidChange

public void clientObjectDidChange(Client client)
Description copied from interface: SessionObserver
For systems that allow switching screen names after logon, this method is called whenever a screen name change takes place to report that the client object has been replaced to potential client-side subscribers.

Specified by:
clientObjectDidChange in interface SessionObserver

clientDidLogoff

public void clientDidLogoff(Client client)
Description copied from interface: SessionObserver
Called after the client has been logged off of the server and has disconnected.

Specified by:
clientDidLogoff in interface SessionObserver

setAvailableInStandalone

public void setAvailableInStandalone(boolean available)
Sets whether or not this director is available in standalone mode.


isAvailableInStandalone

public boolean isAvailableInStandalone()
Checks whether or not this director is available in standalone mode (defaults to false).


isAvailable

protected boolean isAvailable()
Checks whether this director is available in the current mode.


assertAvailable

protected void assertAvailable()
If this director is not currently available, throws a RuntimeException.


clientObjectUpdated

protected void clientObjectUpdated(Client client)
Called in three circumstances: when a director is created and we've already logged on; when we first log on and when the client object changes after we've already logged on.


registerServices

protected void registerServices(Client client)
If a director makes use of bootstrap invocation services which are part of a bootstrap service group, it should register interest in that group here with a call to Client.addServiceGroup(java.lang.String).


fetchServices

protected void fetchServices(Client client)
Derived directors can override this method and obtain any services they'll need during their operation via calls to Client.getService(java.lang.Class). If the director is available, it will automatically be called when the client logs on or when the director is constructed if it is constructed after the client is already logged on.