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:
@@ -20,7 +20,7 @@ public interface EZGameService extends InvocationService
|
||||
*/
|
||||
public void setProperty (
|
||||
Client client, String propName, Object value, int index,
|
||||
boolean testAndSet, InvocationListener listener);
|
||||
boolean testAndSet, Object testValue, InvocationListener listener);
|
||||
|
||||
/**
|
||||
* Request to end the turn, possibly futzing the next turn holder unless
|
||||
|
||||
@@ -61,34 +61,40 @@ public class GameObjectImpl
|
||||
// from EZGame
|
||||
public void set (String propName, Object value)
|
||||
{
|
||||
set(propName, value, -1, false);
|
||||
}
|
||||
|
||||
// from EZGame
|
||||
public void set (String propName, Object value, boolean testAndSet)
|
||||
{
|
||||
set(propName, value, -1, testAndSet);
|
||||
set(propName, value, -1);
|
||||
}
|
||||
|
||||
// from EZGame
|
||||
public void set (String propName, Object value, int index)
|
||||
{
|
||||
set(propName, value, index, false);
|
||||
}
|
||||
|
||||
// from EZGame
|
||||
public void set (String propName, Object value, int index, boolean testAndSet)
|
||||
{
|
||||
validatePropertyChange(propName, value, -1);
|
||||
|
||||
Object encoded = EZObjectMarshaller.encode(value);
|
||||
Object reconstituted = EZObjectMarshaller.decode(encoded);
|
||||
_ezObj.ezGameService.setProperty(
|
||||
_ctx.getClient(), propName, encoded, index, testAndSet,
|
||||
_ctx.getClient(), propName, encoded, index, false, null,
|
||||
createLoggingListener("setProperty"));
|
||||
|
||||
// set it immediately in the game object
|
||||
_ezObj.applyPropertySet(propName, reconstituted, index, testAndSet);
|
||||
_ezObj.applyPropertySet(propName, reconstituted, index);
|
||||
}
|
||||
|
||||
// from EZGame
|
||||
public void testAndSet (String propName, Object value, Object testValue)
|
||||
{
|
||||
testAndSet(propName, value, testValue, -1);
|
||||
}
|
||||
|
||||
// from EZGame
|
||||
public void testAndSet (
|
||||
String propName, Object value, Object testValue, int index)
|
||||
{
|
||||
validatePropertyChange(propName, value, -1);
|
||||
|
||||
Object encoded = EZObjectMarshaller.encode(value);
|
||||
_ezObj.ezGameService.setProperty(
|
||||
_ctx.getClient(), propName, encoded, index, true, testValue,
|
||||
createLoggingListener("testAndSet"));
|
||||
}
|
||||
|
||||
// from EZGame
|
||||
|
||||
Reference in New Issue
Block a user