com.threerings.whirled.server

## Class SceneRegistry

- java.lang.Object
- - com.threerings.whirled.server.SceneRegistry

All Implemented Interfaces:
  com.threerings.crowd.data.LocationCodes, com.threerings.presents.data.InvocationCodes, com.threerings.presents.server.InvocationProvider, SceneCodes, SceneProvider

Direct Known Subclasses:
  SpotSceneRegistry

    public class SceneRegistry
    extends Object
    implements SceneCodes, SceneProvider

The scene registry is responsible for the management of all scenes. It handles interaction with the scene repository and ensures that scenes are loaded into memory when needed and flushed from memory when not needed.

The scene repository also takes care of bridging from the blocking, synchronous world of the scene repository to the non-blocking asynchronous world of the distributed object event queue. Thus its interfaces for accessing scenes are structured so as to not block the dobjmgr thread while waiting for scenes to be read from or written to the repository.

Note: All access to the scene registry should take place from the dobjmgr thread.

### Nested Class Summary

Nested Classes
`static interface` `SceneRegistry.ConfigFactory` Used to create `PlaceConfig` instances for scenes.
`static interface` `SceneRegistry.ResolutionListener` Because scenes must be loaded from the scene repository and this must not be done on the dobjmgr thread, the interface for resolving scenes requires that the entity that wishes for a scene to be resolved implement this callback interface so that it can be notified when a scene has been loaded and initialized.

### Field Summary

### Fields inherited from interface com.threerings.whirled.data.SceneCodes

`SCENE_UPDATE, WHIRLED_GROUP`

### Fields inherited from interface com.threerings.crowd.data.LocationCodes

`ALREADY_THERE, MOVE_IN_PROGRESS, NO_SUCH_PLACE`

### Fields inherited from interface com.threerings.presents.data.InvocationCodes

`ACCESS_DENIED, E_ACCESS_DENIED, E_INTERNAL_ERROR, GLOBAL_GROUP, INTERNAL_ERROR`

### Constructor Summary

Constructors
Constructor and Description
`SceneRegistry(com.threerings.presents.server.InvocationManager invmgr)` Constructs a scene registry.

### Method Summary

All Methods Instance Methods Concrete Methods
`SceneManager` `getSceneManager(int sceneId)` Fetches the scene manager associated with the specified scene.
`SceneRepository` `getSceneRepository()` Returns a reference to the scene repository in use by this registry.
`void` `leaveOccupiedScene(com.threerings.crowd.data.BodyObject source)` Ejects the specified body from their current scene and zone.
`void` `moveBody(com.threerings.crowd.data.BodyObject source, int sceneId)` Ejects the specified body from their current scene and sends them a request to move to the specified new scene.
`void` `moveTo(com.threerings.presents.data.ClientObject caller, int sceneId, int sceneVer, SceneService.SceneMoveListener listener)` Handles a `SceneService.moveTo(int, int, com.threerings.whirled.client.SceneService.SceneMoveListener)` request.
`void` `resolveScene(int sceneId, SceneRegistry.ResolutionListener target)` Requests that the specified scene be resolved, which means loaded into the server and initialized if the scene is not currently active.
`String` `where(int sceneId)` Returns `SceneManager.where()` for the specified scene or `null:sceneId` if no scene manager exists for that scene.

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

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

### Constructor Detail

#### SceneRegistry

    @Inject
    public SceneRegistry(com.threerings.presents.server.InvocationManager invmgr)

Constructs a scene registry.

### Method Detail

#### getSceneManager

    public SceneManager getSceneManager(int sceneId)

Fetches the scene manager associated with the specified scene.

Returns:
  the scene manager for the specified scene or null if no scene manager is loaded for that scene.

#### getSceneRepository

    public SceneRepository getSceneRepository()

Returns a reference to the scene repository in use by this registry.

#### where

    public String where(int sceneId)

Returns `SceneManager.where()` for the specified scene or `null:sceneId` if no scene manager exists for that scene.

#### resolveScene

    public void resolveScene(int sceneId,
                             SceneRegistry.ResolutionListener target)

Requests that the specified scene be resolved, which means loaded into the server and initialized if the scene is not currently active. The supplied callback instance will be notified, on the dobjmgr thread, when the scene has been resolved. If the scene is already active, it will be notified immediately (before the call to `resolveScene(int, com.threerings.whirled.server.SceneRegistry.ResolutionListener)` returns).

Parameters:
  `sceneId` - the id of the scene to resolve.
  `target` - a reference to a callback instance that will be notified when the scene has been resolved (which may be immediately if the scene is already active).

#### moveTo

    public void moveTo(com.threerings.presents.data.ClientObject caller,
                       int sceneId,
                       int sceneVer,
                       SceneService.SceneMoveListener listener)

Description copied from interface: `SceneProvider`
Handles a `SceneService.moveTo(int, int, com.threerings.whirled.client.SceneService.SceneMoveListener)` request.

Specified by:
  `moveTo` in interface `SceneProvider`

#### moveBody

    public void moveBody(com.threerings.crowd.data.BodyObject source,
                         int sceneId)

Ejects the specified body from their current scene and sends them a request to move to the specified new scene. This is the scene-equivalent to `LocationProvider.moveTo(com.threerings.presents.data.ClientObject, int, com.threerings.crowd.client.LocationService.MoveListener)`.

#### leaveOccupiedScene

    public void leaveOccupiedScene(com.threerings.crowd.data.BodyObject source)

Ejects the specified body from their current scene and zone. This is the zone equivalent to `LocationProvider.leavePlace(com.threerings.presents.data.ClientObject)`.