Allow a scene manager to declare that it isn't persistent and skip updating the scene repository if that's the case
git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@595 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -66,6 +66,15 @@ public class SceneManager extends PlaceManager
|
||||
return new ScenePlace(_plobj.getOid(), _scene.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this scene stores data in the database, or false if it's instantiated anew
|
||||
* with each server restart
|
||||
*/
|
||||
public boolean isPersistent ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the scene registry once the scene manager has been created (and initialized), but
|
||||
* before it is started up.
|
||||
@@ -146,17 +155,20 @@ public class SceneManager extends PlaceManager
|
||||
_updates.addUpdate(update);
|
||||
|
||||
// and apply and store it in the repository
|
||||
WhirledServer.invoker.postUnit(new Invoker.Unit() {
|
||||
public boolean invoke () {
|
||||
try {
|
||||
_screg.getSceneRepository().applyAndRecordUpdate(_scene.getSceneModel(), update);
|
||||
} catch (PersistenceException pe) {
|
||||
Log.warning("Failed to apply scene update " + update + ".");
|
||||
Log.logStackTrace(pe);
|
||||
if (isPersistent()) {
|
||||
WhirledServer.invoker.postUnit(new Invoker.Unit() {
|
||||
public boolean invoke () {
|
||||
try {
|
||||
_screg.getSceneRepository().applyAndRecordUpdate(_scene.getSceneModel(),
|
||||
update);
|
||||
} catch (PersistenceException pe) {
|
||||
Log.warning("Failed to apply scene update " + update + ".");
|
||||
Log.logStackTrace(pe);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// broadcast the update to all occupants of the scene
|
||||
_plobj.postMessage(SceneCodes.SCENE_UPDATE, new Object[] { update });
|
||||
|
||||
Reference in New Issue
Block a user