com.threerings.whirled.zone.client
Class ZoneDirector

java.lang.Object
  extended by com.threerings.presents.client.BasicDirector
      extended by com.threerings.whirled.zone.client.ZoneDirector
All Implemented Interfaces:
InvocationReceiver, InvocationService.InvocationListener, SessionObserver, SceneDirector.MoveHandler, ZoneReceiver, ZoneService.ZoneMoveListener

public class ZoneDirector
extends BasicDirector
implements ZoneReceiver, ZoneService.ZoneMoveListener, SceneDirector.MoveHandler

The zone director augments the scene services with the notion of zones. Zones are self-contained, connected groups of scenes. The normal scene director services can be used to move from scene to scene, but moving to a new zone requires a special move request which can be accomplished via the zone director. The zone director also makes available the zone summary which provides information on the zone which can be used to generate an overview map or similar.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.threerings.presents.client.InvocationReceiver
InvocationReceiver.Registration
 
Field Summary
protected  WhirledContext _ctx
          A reference to the active client context.
protected  ArrayList<ZoneObserver> _observers
          Our zone observer list.
protected  int _pendingZoneId
          Where we're headed.
protected  int _previousZoneId
          Our previous zone id.
protected  SceneDirector _scdir
          A reference to the scene director with which we coordinate.
protected  ZoneSummary _summary
          A reference to the zone summary for the currently occupied zone.
protected  ZoneService _zservice
          Provides access to zone services.
 
Fields inherited from class com.threerings.presents.client.BasicDirector
_availableInStandalone
 
Constructor Summary
ZoneDirector(WhirledContext ctx, SceneDirector scdir)
          Constructs a zone director with the supplied context, and delegate scene director (which the zone director will coordinate with when moving from scene to scene).
 
Method Summary
 void addZoneObserver(ZoneObserver observer)
          Adds a zone observer to the list.
 void clientDidLogoff(Client client)
           
protected  void fetchServices(Client client)
           
 void forcedMove(int zoneId, int sceneId)
          Used to communicate a required move notification to the client.
 ZoneSummary getZoneSummary()
          Returns the summary for the zone currently occupied by the client or null if the client does not currently occupy a zone (not a normal situation).
 void moveRequiresServerSwitch(String hostname, int[] ports)
          Indicates that the client must switch to the specified server and reissue its move request in order to relocate to its desired zone.
 void moveSucceeded(int placeId, PlaceConfig config, ZoneSummary summary)
          Called in response to a successful ZoneService.moveTo(com.threerings.presents.client.Client, int, int, int, com.threerings.whirled.zone.client.ZoneService.ZoneMoveListener) request.
 void moveSucceededWithScene(int placeId, PlaceConfig config, ZoneSummary summary, SceneModel model)
          Called in response to a successful ZoneService.moveTo(com.threerings.presents.client.Client, int, int, int, com.threerings.whirled.zone.client.ZoneService.ZoneMoveListener) request when our cached scene was out of date and the server determined that we needed an updated copy.
 void moveSucceededWithUpdates(int placeId, PlaceConfig config, ZoneSummary summary, SceneUpdate[] updates)
          Called in response to a successful ZoneService.moveTo(com.threerings.presents.client.Client, int, int, int, com.threerings.whirled.zone.client.ZoneService.ZoneMoveListener) request when our cached scene was out of date and the server determined that we needed some updates.
 boolean moveTo(int zoneId, int sceneId)
          Requests that this client move the specified scene in the specified zone.
 boolean moveTo(int zoneId, int sceneId, com.samskivert.util.ResultListener<PlaceConfig> rl)
          Requests that this client move the specified scene in the specified zone.
protected  void notifyObservers(Object data)
          Notifies observers of success or failure, depending on the type of object provided as data.
 void recoverMoveTo(int previousSceneId)
          Should instruct the client to move the last known working location (as well as clean up after the failed moveTo request).
 void removeZoneObserver(ZoneObserver observer)
          Removes a zone observer from the list.
 void requestFailed(String reason)
           
protected  void sendMoveRequest()
           
 
Methods inherited from class com.threerings.presents.client.BasicDirector
assertAvailable, clientDidLogon, clientObjectDidChange, clientObjectUpdated, clientWillLogon, isAvailable, isAvailableInStandalone, registerServices, setAvailableInStandalone
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_ctx

protected WhirledContext _ctx
A reference to the active client context.


_scdir

protected SceneDirector _scdir
A reference to the scene director with which we coordinate.


_zservice

protected ZoneService _zservice
Provides access to zone services.


_summary

protected ZoneSummary _summary
A reference to the zone summary for the currently occupied zone.


_observers

protected ArrayList<ZoneObserver> _observers
Our zone observer list.


_previousZoneId

protected int _previousZoneId
Our previous zone id.


_pendingZoneId

protected int _pendingZoneId
Where we're headed.

Constructor Detail

ZoneDirector

public ZoneDirector(WhirledContext ctx,
                    SceneDirector scdir)
Constructs a zone director with the supplied context, and delegate scene director (which the zone director will coordinate with when moving from scene to scene). A zone director is required on the client side for systems that wish to use the zone services.

Method Detail

getZoneSummary

public ZoneSummary getZoneSummary()
Returns the summary for the zone currently occupied by the client or null if the client does not currently occupy a zone (not a normal situation).


addZoneObserver

public void addZoneObserver(ZoneObserver observer)
Adds a zone observer to the list. This observer will subsequently be notified of effected and failed zone changes.


removeZoneObserver

public void removeZoneObserver(ZoneObserver observer)
Removes a zone observer from the list.


moveTo

public boolean moveTo(int zoneId,
                      int sceneId)
Requests that this client move the specified scene in the specified zone. A request will be made and when the response is received, the location observers will be notified of success or failure.


moveTo

public boolean moveTo(int zoneId,
                      int sceneId,
                      com.samskivert.util.ResultListener<PlaceConfig> rl)
Requests that this client move the specified scene in the specified zone. A request will be made and when the response is received, the location observers will be notified of success or failure.


sendMoveRequest

protected void sendMoveRequest()

fetchServices

protected void fetchServices(Client client)
Overrides:
fetchServices in class BasicDirector

clientDidLogoff

public void clientDidLogoff(Client client)
Specified by:
clientDidLogoff in interface SessionObserver
Overrides:
clientDidLogoff in class BasicDirector

moveRequiresServerSwitch

public void moveRequiresServerSwitch(String hostname,
                                     int[] ports)
Description copied from interface: ZoneService.ZoneMoveListener
Indicates that the client must switch to the specified server and reissue its move request in order to relocate to its desired zone.

Specified by:
moveRequiresServerSwitch in interface ZoneService.ZoneMoveListener

moveSucceeded

public void moveSucceeded(int placeId,
                          PlaceConfig config,
                          ZoneSummary summary)
Description copied from interface: ZoneService.ZoneMoveListener
Called in response to a successful ZoneService.moveTo(com.threerings.presents.client.Client, int, int, int, com.threerings.whirled.zone.client.ZoneService.ZoneMoveListener) request.

Specified by:
moveSucceeded in interface ZoneService.ZoneMoveListener

moveSucceededWithUpdates

public void moveSucceededWithUpdates(int placeId,
                                     PlaceConfig config,
                                     ZoneSummary summary,
                                     SceneUpdate[] updates)
Description copied from interface: ZoneService.ZoneMoveListener
Called in response to a successful ZoneService.moveTo(com.threerings.presents.client.Client, int, int, int, com.threerings.whirled.zone.client.ZoneService.ZoneMoveListener) request when our cached scene was out of date and the server determined that we needed some updates.

Specified by:
moveSucceededWithUpdates in interface ZoneService.ZoneMoveListener

moveSucceededWithScene

public void moveSucceededWithScene(int placeId,
                                   PlaceConfig config,
                                   ZoneSummary summary,
                                   SceneModel model)
Description copied from interface: ZoneService.ZoneMoveListener
Called in response to a successful ZoneService.moveTo(com.threerings.presents.client.Client, int, int, int, com.threerings.whirled.zone.client.ZoneService.ZoneMoveListener) request when our cached scene was out of date and the server determined that we needed an updated copy.

Specified by:
moveSucceededWithScene in interface ZoneService.ZoneMoveListener

requestFailed

public void requestFailed(String reason)
Specified by:
requestFailed in interface InvocationService.InvocationListener

forcedMove

public void forcedMove(int zoneId,
                       int sceneId)
Description copied from interface: ZoneReceiver
Used to communicate a required move notification to the client. The server will have removed the client from their existing scene and the client is then responsible for generating a ZoneService.moveTo(com.threerings.presents.client.Client, int, int, int, com.threerings.whirled.zone.client.ZoneService.ZoneMoveListener) request to move to the new scene in the specified zone.

Specified by:
forcedMove in interface ZoneReceiver

recoverMoveTo

public void recoverMoveTo(int previousSceneId)
Description copied from interface: SceneDirector.MoveHandler
Should instruct the client to move the last known working location (as well as clean up after the failed moveTo request).

Specified by:
recoverMoveTo in interface SceneDirector.MoveHandler

notifyObservers

protected void notifyObservers(Object data)
Notifies observers of success or failure, depending on the type of object provided as data.