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());
|
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
|
* Called by the scene registry once the scene manager has been created (and initialized), but
|
||||||
* before it is started up.
|
* before it is started up.
|
||||||
@@ -146,17 +155,20 @@ public class SceneManager extends PlaceManager
|
|||||||
_updates.addUpdate(update);
|
_updates.addUpdate(update);
|
||||||
|
|
||||||
// and apply and store it in the repository
|
// and apply and store it in the repository
|
||||||
WhirledServer.invoker.postUnit(new Invoker.Unit() {
|
if (isPersistent()) {
|
||||||
public boolean invoke () {
|
WhirledServer.invoker.postUnit(new Invoker.Unit() {
|
||||||
try {
|
public boolean invoke () {
|
||||||
_screg.getSceneRepository().applyAndRecordUpdate(_scene.getSceneModel(), update);
|
try {
|
||||||
} catch (PersistenceException pe) {
|
_screg.getSceneRepository().applyAndRecordUpdate(_scene.getSceneModel(),
|
||||||
Log.warning("Failed to apply scene update " + update + ".");
|
update);
|
||||||
Log.logStackTrace(pe);
|
} 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
|
// broadcast the update to all occupants of the scene
|
||||||
_plobj.postMessage(SceneCodes.SCENE_UPDATE, new Object[] { update });
|
_plobj.postMessage(SceneCodes.SCENE_UPDATE, new Object[] { update });
|
||||||
|
|||||||
Reference in New Issue
Block a user