When a scene update is received while in the scene, apply it immediately

and also save the new updated model.


git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@19 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Ray Greenwell
2006-07-13 17:47:55 +00:00
parent 280b55061a
commit 19f22b01f1
4 changed files with 56 additions and 43 deletions
@@ -71,12 +71,7 @@ public /*abstract*/ class SceneController extends PlaceController
protected function sceneUpdated (update :SceneUpdate) :void
{
// apply the update to the scene
_wctx.getSceneDirector().getScene().updateReceived(update);
// we don't persistify these updates in this circumstance, but
// next time we come to this scene we'll redownload the update and
// apply it to the repository; as the updates are meant to be very
// small, this shouldn't be horribly less efficient
_wctx.getSceneDirector().updateReceived(update);
}
/** Used to listen for scene updates. */
@@ -305,13 +305,7 @@ public class SceneDirector extends BasicDirector
}
// store the updated scene in the repository
try {
_screp.storeSceneModel(model);
} catch (ioe :IOError) {
log.warning("Failed to update repository with updated scene " +
"[sceneId=" + model.sceneId + "].");
log.logStackTrace(ioe);
}
persistSceneModel(model);
// finally pass through to the normal success handler
moveSucceeded(placeId, config);
@@ -326,14 +320,7 @@ public class SceneDirector extends BasicDirector
model.name + "/" + model.version + "].");
// update the model in the repository
try {
_screp.storeSceneModel(model);
} catch (ioe :IOError) {
log.warning("Failed to update repository with new version " +
"[sceneId=" + model.sceneId +
", nvers=" + model.version + "].");
log.logStackTrace(ioe);
}
persistSceneModel(model);
// update our scene cache
_scache.put(model.sceneId, model);
@@ -353,6 +340,16 @@ public class SceneDirector extends BasicDirector
_locdir.failedToMoveTo(sceneId, reason);
}
/**
* Called by SceneController instances to tell us about an update
* to the current scene.
*/
public function updateReceived (update :SceneUpdate) :void
{
_scene.updateReceived(update);
persistSceneModel(_scene.getSceneModel());
}
/**
* Called to clean up our place and scene state information when we
* leave a scene.
@@ -462,6 +459,20 @@ public class SceneDirector extends BasicDirector
return model;
}
/**
* Persist the scene model to the clientside persistant cache.
*/
protected function persistSceneModel (model :SceneModel) :void
{
try {
_screp.storeSceneModel(model);
} catch (ioe :IOError) {
log.warning("Failed to update repository with updated scene " +
"[sceneId=" + model.sceneId + "].");
log.logStackTrace(ioe);
}
}
// documentation inherited
override public function clientDidLogoff (event :ClientEvent) :void
{
@@ -70,12 +70,7 @@ public abstract class SceneController extends PlaceController
protected void sceneUpdated (SceneUpdate update)
{
// apply the update to the scene
_wctx.getSceneDirector().getScene().updateReceived(update);
// we don't persistify these updates in this circumstance, but
// next time we come to this scene we'll redownload the update and
// apply it to the repository; as the updates are meant to be very
// small, this shouldn't be horribly less efficient
_wctx.getSceneDirector().updateReceived(update);
}
/** Used to listen for scene updates. */
@@ -309,14 +309,8 @@ public class SceneDirector extends BasicDirector
return;
}
// store the updated scene in the repository
try {
_screp.storeSceneModel(model);
} catch (IOException ioe) {
Log.warning("Failed to update repository with updated scene " +
"[sceneId=" + model.sceneId + "].");
Log.logStackTrace(ioe);
}
// store the updated version
persistSceneModel(model);
// finally pass through to the normal success handler
moveSucceeded(placeId, config);
@@ -331,14 +325,7 @@ public class SceneDirector extends BasicDirector
model.name + "/" + model.version + "].");
// update the model in the repository
try {
_screp.storeSceneModel(model);
} catch (IOException ioe) {
Log.warning("Failed to update repository with new version " +
"[sceneId=" + model.sceneId +
", nvers=" + model.version + "].");
Log.logStackTrace(ioe);
}
persistSceneModel(model);
// update our scene cache
_scache.put(Integer.valueOf(model.sceneId), model);
@@ -358,6 +345,16 @@ public class SceneDirector extends BasicDirector
_locdir.failedToMoveTo(sceneId, reason);
}
/**
* Called by SceneController instances to tell us about an update
* to the current scene.
*/
public void updateReceived (SceneUpdate update)
{
_scene.updateReceived(update);
persistSceneModel(_scene.getSceneModel());
}
/**
* Called to clean up our place and scene state information when we
* leave a scene.
@@ -468,6 +465,21 @@ public class SceneDirector extends BasicDirector
return model;
}
/**
* Persist the scene model to the clientside persistant cache.
*/
protected void persistSceneModel (SceneModel model)
{
// store the updated scene in the repository
try {
_screp.storeSceneModel(model);
} catch (IOException ioe) {
Log.warning("Failed to update repository with updated scene " +
"[sceneId=" + model.sceneId + "].");
Log.logStackTrace(ioe);
}
}
// documentation inherited from interface
public void clientDidLogoff (Client client)
{