Apply additions and removals to OidList fields on DObjects immediately on the server to make it

match DSets and setting attributes.  With the old behvaior, if a client subscribed to a DObject and
modified an OidList on it in a single pass, it could miss the modification.  The DObject is
serialized immediately when the server gets the subscription request, but events aren't sent for
that subscription till it's processed the next time the omgr queue comes round.



git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6420 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Charlie Groves
2011-01-06 09:15:47 +00:00
parent b4af8a0384
commit 8f8a50c9e8
6 changed files with 64 additions and 21 deletions
@@ -42,9 +42,15 @@ public class ObjectAddedEvent extends NamedEvent
* @param oid the oid to add to the oid list attribute.
*/
public ObjectAddedEvent (int targetOid, String name, int oid)
{
this(targetOid, name, oid, false);
}
protected ObjectAddedEvent (int targetOid, String name, int oid, boolean alreadyApplied)
{
super(targetOid, name);
_oid = oid;
_alreadyApplied = alreadyApplied;
}
/**
@@ -63,12 +69,20 @@ public class ObjectAddedEvent extends NamedEvent
return _oid;
}
@Override
public boolean alreadyApplied ()
{
return _alreadyApplied;
}
@Override
public boolean applyToObject (DObject target)
throws ObjectAccessException
{
OidList list = (OidList)target.getAttribute(_name);
list.add(_oid);
if (!_alreadyApplied) {
OidList list = (OidList)target.getAttribute(_name);
list.add(_oid);
}
return true;
}
@@ -89,4 +103,5 @@ public class ObjectAddedEvent extends NamedEvent
}
protected int _oid;
protected transient boolean _alreadyApplied;
}