Step two in the great Stage refactor. I don't know how many steps will be

needed all told, but I like to see the number keep going up.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3438 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2005-03-29 23:18:59 +00:00
parent d60445e16b
commit 0bf43bc2e8
14 changed files with 1290 additions and 78 deletions
@@ -127,32 +127,35 @@ public class SceneManager extends PlaceManager
/**
* When a modification is made to a scene, the scene manager should
* update its internal structures, update the {@link Scene} object,
* update the repository (either by storing the updated scene
* wholesale or more efficiently updating only what has changed), and
* then it should create a {@link SceneUpdate} record that can be
* delivered to clients to effect the update to the clients's cached
* copy of the scene model. This update will be stored persistently
* and provided (along with any other accumulated updates) to clients
* that later request to enter the scene with an old version of the
* scene data. Updates are not stored forever, but a sizable number of
* recent updates are stored so that moderately current clients can
* apply incremental patches to their scenes rather than redownloading
* the entire scenes when they change.
* create a SceneUpdate instance and pass it to this method which will
* update the in-memory scene, and apply and record the update in the
* scene repository.
*
* <p> This update will be stored persistently and provided (along
* with any other accumulated updates) to clients that later request
* to enter the scene with an old version of the scene data. Updates
* are not stored forever, but a sizable number of recent updates are
* stored so that moderately current clients can apply incremental
* patches to their scenes rather than redownloading entire scenes
* when they change.
*/
protected void recordUpdate (final SceneUpdate update)
{
// instruct our in-memory copy of the scene to apply the update
_scene.updateReceived(update);
// add it to our in memory update list
_updates.addUpdate(update);
// and store it in the repository
// and apply and store it in the repository
WhirledServer.invoker.postUnit(new Invoker.Unit() {
public boolean invoke () {
try {
_screg.getSceneRepository().addUpdate(update);
_screg.getSceneRepository().applyAndRecordUpdate(
_scene.getSceneModel(), update);
} catch (PersistenceException pe) {
Log.warning("Failed to store scene update " +
"[update=" + update + ", error=" + pe + "].");
Log.warning("Failed to apply scene update " + update + ".");
Log.logStackTrace(pe);
}
return false;
}
@@ -1,5 +1,5 @@
//
// $Id: DummySceneRepository.java,v 1.9 2004/08/27 02:20:43 mdb Exp $
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -52,7 +52,7 @@ public class DummySceneRepository implements SceneRepository
}
// documentation inherited from interface
public void addUpdate (SceneUpdate update)
public void applyAndRecordUpdate (SceneModel model, SceneUpdate update)
throws PersistenceException
{
// nothing doing
@@ -1,5 +1,5 @@
//
// $Id: SceneRepository.java,v 1.7 2004/08/27 02:20:43 mdb Exp $
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -60,12 +60,14 @@ public interface SceneRepository
throws PersistenceException, NoSuchSceneException;
/**
* Adds the supplied scene update to the list of updates for its
* associated scene.
* Applise the supplied scene update to persistent representation of
* its associated scene, then stores the update persistently for
* future invocations of the server to load. <em>Note:</em> the scene
* update will have already been applied to the supplied scene model.
*
* @exception PersistenceException thrown if an error occurs
* attempting to store the scene update.
* attempting to apply the scene update.
*/
public void addUpdate (SceneUpdate update)
public void applyAndRecordUpdate (SceneModel model, SceneUpdate update)
throws PersistenceException;
}