Fixes for property setting via atomic test-and-set:

- Moved property testing, so that it happens before any propertySet events are
  dispatched. In the previous version, testing happened while processing the
  set event on the server - but since by that time client events have already been 
  sent, it introduced the possibility of short-lived inconsistencies between client 
  and server data models.   

- Introduced a separate EZ API call for test and set - not only does it perform
  the test, but unlike regular set, it does not cache the new value ahead of time. 
  Instead the new value will have to arrive from the server, at some future point.

- Trimmed PropertySetEvent and other handlers back down - they don't need to
  carry any of the test info around, after it's already been performed. Also 
  cut redundant testing on the clients.




git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@195 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Robert Zubeck
2007-02-19 19:40:09 +00:00
parent e21ad04665
commit 83e02730cf
16 changed files with 183 additions and 123 deletions
+12 -5
View File
@@ -153,24 +153,31 @@ public class EZGameControl extends EventDispatcher
}
/**
* Set a property that will be distributed.
* Set a property that will be distributed.
*/
public function set (propName :String, value :Object, index :int = -1) :void
{
callEZCode("setProperty_v2", propName, value, index, false);
callEZCode("setProperty_v1", propName, value, index);
}
/**
* Set a property that will be distributed, but only if it was null before.
* Set a property that will be distributed, but only if it's equal
* to the specified test value.
*
* Please note that, unlike in the standard set() function, the property
* will not be updated right away, but will require a request to the server
* and a response back. For this reason, there may be a considerable delay
* between calling testAndSet, and seeing the result of the update.
*
* The operation is 'atomic', in the sense that testing and setting take place
* during the same server event. In comparison, a separate 'get' followed by
* a 'set' operation would involve two events with two network round-trips,
* and no guarantee that the value won't change between the events.
*/
public function testAndSet (propName :String, value :Object, index :int = -1) :void
public function testAndSet (
propName :String, newValue :Object, testValue :Object, index :int = -1) :void
{
callEZCode("setProperty_v2", propName, value, index, true);
callEZCode("testAndSetProperty_v1", propName, newValue, testValue, index);
}
/**