com.threerings.whirled.zone.client

## Class ZoneDirector

- java.lang.Object
- - com.threerings.presents.client.BasicDirector
  - - com.threerings.whirled.zone.client.ZoneDirector

All Implemented Interfaces:
  com.threerings.presents.client.InvocationReceiver, com.threerings.presents.client.InvocationService.InvocationListener, com.threerings.presents.client.SessionObserver, SceneDirector.MoveHandler, ZoneReceiver, ZoneService.ZoneMoveListener

    public class ZoneDirector
    extends com.threerings.presents.client.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

`com.threerings.presents.client.InvocationReceiver.Registration`

### Constructor Summary

Constructors
Constructor and Description
`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

All Methods Instance Methods Concrete Methods
`void` `addZoneObserver(ZoneObserver observer)` Adds a zone observer to the list.
`void` `clientDidLogoff(com.threerings.presents.client.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, com.threerings.crowd.data.PlaceConfig config, ZoneSummary summary)` Called in response to a successful `ZoneService.moveTo(int, int, int, com.threerings.whirled.zone.client.ZoneService.ZoneMoveListener)` request.
`void` `moveSucceededWithScene(int placeId, com.threerings.crowd.data.PlaceConfig config, ZoneSummary summary, SceneModel model)` Called in response to a successful `ZoneService.moveTo(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, com.threerings.crowd.data.PlaceConfig config, ZoneSummary summary, SceneUpdate[] updates)` Called in response to a successful `ZoneService.moveTo(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, ResultListener<com.threerings.crowd.data.PlaceConfig> rl)` Requests that this client move the specified scene in the specified zone.
`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)`

### Methods inherited from class com.threerings.presents.client.BasicDirector

`clientDidLogon, clientObjectDidChange, clientWillLogon, isAvailableInStandalone, setAvailableInStandalone`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### 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,
                          ResultListener<com.threerings.crowd.data.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.

#### clientDidLogoff

    public void clientDidLogoff(com.threerings.presents.client.Client client)

Specified by:
  `clientDidLogoff` in interface `com.threerings.presents.client.SessionObserver`
Overrides:
  `clientDidLogoff` in class `com.threerings.presents.client.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,
                              com.threerings.crowd.data.PlaceConfig config,
                              ZoneSummary summary)

Description copied from interface: `ZoneService.ZoneMoveListener`
Called in response to a successful `ZoneService.moveTo(int, int, int, com.threerings.whirled.zone.client.ZoneService.ZoneMoveListener)` request.

Specified by:
  `moveSucceeded` in interface `ZoneService.ZoneMoveListener`

#### moveSucceededWithUpdates

    public void moveSucceededWithUpdates(int placeId,
                                         com.threerings.crowd.data.PlaceConfig config,
                                         ZoneSummary summary,
                                         SceneUpdate[] updates)

Description copied from interface: `ZoneService.ZoneMoveListener`
Called in response to a successful `ZoneService.moveTo(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,
                                       com.threerings.crowd.data.PlaceConfig config,
                                       ZoneSummary summary,
                                       SceneModel model)

Description copied from interface: `ZoneService.ZoneMoveListener`
Called in response to a successful `ZoneService.moveTo(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 `com.threerings.presents.client.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(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`