For EZ property sets, added a setter that performs an "atomic" test-and-set:
it's atomic in the sense that a single server event will test the variable, and only set it if the previous value was null (i.e. didn't exist). This allows for a level of elementary synchronization between the clients. The new function on EZGameControl is: _gameCtrl.testAndSet (propertyName, newValue[, index]) I hoped to generalize this to test against arbitrary values, but that's significantly harder, since properties accept numerous types as values, and those can have different representations on the client and the server. So it remains a check against null until we need to generalize it. :) git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@193 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -174,15 +174,6 @@ public class DictionaryService
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obsolete init function. I'm keeping it around to prevent
|
||||
* any automated build breakage between the upcoming Vilya checkin
|
||||
* and the subsequent MSoy checkin. But this will go away real soon.
|
||||
*/
|
||||
public static void init ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the singleton instance of the dictionary service.
|
||||
*/
|
||||
|
||||
@@ -129,7 +129,7 @@ public class EZGameDispatcher extends InvocationDispatcher
|
||||
case EZGameMarshaller.SET_PROPERTY:
|
||||
((EZGameProvider)provider).setProperty(
|
||||
source,
|
||||
(String)args[0], (Object)args[1], ((Integer)args[2]).intValue(), (InvocationService.InvocationListener)args[3]
|
||||
(String)args[0], (Object)args[1], ((Integer)args[2]).intValue(), ((Boolean)args[3]).booleanValue(), (InvocationService.InvocationListener)args[4]
|
||||
);
|
||||
return;
|
||||
|
||||
|
||||
@@ -127,11 +127,11 @@ public class EZGameManager extends GameManager
|
||||
// from EZGameProvider
|
||||
public void setProperty (
|
||||
ClientObject caller, String propName, Object data, int index,
|
||||
InvocationService.InvocationListener listener)
|
||||
boolean testAndSet, InvocationService.InvocationListener listener)
|
||||
throws InvocationException
|
||||
{
|
||||
validateUser(caller);
|
||||
setProperty(propName, data, index);
|
||||
setProperty(propName, data, index, testAndSet);
|
||||
}
|
||||
|
||||
// from EZGameProvider
|
||||
@@ -220,7 +220,7 @@ public class EZGameManager extends GameManager
|
||||
}
|
||||
|
||||
if (playerId == 0) {
|
||||
setProperty(msgOrPropName, result, -1);
|
||||
setProperty(msgOrPropName, result, -1, false);
|
||||
|
||||
} else {
|
||||
sendPrivateMessage(playerId, msgOrPropName, result);
|
||||
@@ -400,10 +400,12 @@ public class EZGameManager extends GameManager
|
||||
/**
|
||||
* Helper method to post a property set event.
|
||||
*/
|
||||
protected void setProperty (String propName, Object value, int index)
|
||||
protected void setProperty (
|
||||
String propName, Object value, int index, boolean testAndSet)
|
||||
{
|
||||
_gameObj.postEvent(
|
||||
new PropertySetEvent(_gameObj.getOid(), propName, value, index));
|
||||
new PropertySetEvent(
|
||||
_gameObj.getOid(), propName, value, index, testAndSet));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -96,7 +96,7 @@ public interface EZGameProvider extends InvocationProvider
|
||||
/**
|
||||
* Handles a {@link EZGameService#setProperty} request.
|
||||
*/
|
||||
public void setProperty (ClientObject caller, String arg1, Object arg2, int arg3, InvocationService.InvocationListener arg4)
|
||||
public void setProperty (ClientObject caller, String arg1, Object arg2, int arg3, boolean arg4, InvocationService.InvocationListener arg5)
|
||||
throws InvocationException;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user