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:
@@ -127,11 +127,12 @@ public class EZGameManager extends GameManager
|
||||
// from EZGameProvider
|
||||
public void setProperty (
|
||||
ClientObject caller, String propName, Object data, int index,
|
||||
boolean testAndSet, InvocationService.InvocationListener listener)
|
||||
boolean testAndSet, Object testValue,
|
||||
InvocationService.InvocationListener listener)
|
||||
throws InvocationException
|
||||
{
|
||||
validateUser(caller);
|
||||
setProperty(propName, data, index, testAndSet);
|
||||
setProperty(propName, data, index, testAndSet, testValue);
|
||||
}
|
||||
|
||||
// from EZGameProvider
|
||||
@@ -220,7 +221,7 @@ public class EZGameManager extends GameManager
|
||||
}
|
||||
|
||||
if (playerId == 0) {
|
||||
setProperty(msgOrPropName, result, -1, false);
|
||||
setProperty(msgOrPropName, result, -1, false, null);
|
||||
|
||||
} else {
|
||||
sendPrivateMessage(playerId, msgOrPropName, result);
|
||||
@@ -401,11 +402,15 @@ public class EZGameManager extends GameManager
|
||||
* Helper method to post a property set event.
|
||||
*/
|
||||
protected void setProperty (
|
||||
String propName, Object value, int index, boolean testAndSet)
|
||||
String propName, Object value, int index,
|
||||
boolean testAndSet, Object testValue)
|
||||
{
|
||||
_gameObj.postEvent(
|
||||
new PropertySetEvent(
|
||||
_gameObj.getOid(), propName, value, index, testAndSet));
|
||||
if (_gameObj.testProperty (propName, index, testAndSet, testValue))
|
||||
{
|
||||
_gameObj.postEvent(
|
||||
new PropertySetEvent(
|
||||
_gameObj.getOid(), propName, value, index));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user