Exposed a method to allow users to batch property set requests into a
dobj transaction. Thanks to mdb for the idea of accepting a function to run for the batch, rather than exposing startTransaction() and commitTransaction() directly. git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@317 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -265,6 +265,29 @@ public class EZGameControl extends BaseControl
|
|||||||
callEZCode("testAndSetProperty_v1", propName, newValue, testValue, index);
|
callEZCode("testAndSetProperty_v1", propName, newValue, testValue, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the specified function as a batch of commands that will be sent to the server
|
||||||
|
* together. This is no different from executing the commands outside of a batch, but
|
||||||
|
* may result in better use of the network and should be used if setting a number of things
|
||||||
|
* at once.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* _ctrl.doBatch(function () :void {
|
||||||
|
* _ctrl.set("board", new Array());
|
||||||
|
* _ctrl.set("scores", new Array());
|
||||||
|
* _ctrl.set("captures", 0);
|
||||||
|
* });
|
||||||
|
*/
|
||||||
|
public function doBatch (fn :Function) :void
|
||||||
|
{
|
||||||
|
callEZCode("startTransaction");
|
||||||
|
try {
|
||||||
|
fn();
|
||||||
|
} finally {
|
||||||
|
callEZCode("commitTransaction");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the names of all currently-set properties that begin with the specified prefix.
|
* Get the names of all currently-set properties that begin with the specified prefix.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -218,6 +218,9 @@ public class GameControlBackend
|
|||||||
o["getPlayers_v1"] = getPlayers_v1;
|
o["getPlayers_v1"] = getPlayers_v1;
|
||||||
o["getPlayerPosition_v1"] = getPlayerPosition_v1;
|
o["getPlayerPosition_v1"] = getPlayerPosition_v1;
|
||||||
o["getMyPosition_v1"] = getMyPosition_v1;
|
o["getMyPosition_v1"] = getMyPosition_v1;
|
||||||
|
|
||||||
|
o["startTransaction"] = startTransaction_v1;
|
||||||
|
o["commitTransaction"] = commitTransaction_v1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -590,6 +593,23 @@ public class GameControlBackend
|
|||||||
_container.setFocus();
|
_container.setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start a dobj transaction on the game object.
|
||||||
|
*/
|
||||||
|
public function startTransaction_v1 () :void
|
||||||
|
{
|
||||||
|
validateConnected();
|
||||||
|
_ezObj.startTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Commit a dobj transaction on the game object.
|
||||||
|
*/
|
||||||
|
public function commitTransaction_v1 () :void
|
||||||
|
{
|
||||||
|
_ezObj.commitTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience function to get our name.
|
* Convenience function to get our name.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user