Added a standard mechanism for customizing the AccessController on a

PlaceObject. Created a default AccessController that is slightly more strict
than the CrowdServer-wide default in that it only allows place occupants to
subscribe to a PlaceObject (a motivated and resourceful player could otherwise
listen in on place chat everywhere in the game if they so desired; with a
custom client, of course).


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4079 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2006-04-30 19:16:05 +00:00
parent 2df0c56f2a
commit 0699eb3d1c
2 changed files with 41 additions and 2 deletions
@@ -21,6 +21,7 @@
package com.threerings.crowd.server;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.dobj.AccessController;
import com.threerings.presents.dobj.DEvent;
import com.threerings.presents.dobj.DObject;
@@ -31,6 +32,7 @@ import com.threerings.presents.dobj.Subscriber;
import com.threerings.crowd.Log;
import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.PlaceObject;
/**
* Defines the various object access controllers used by the Crowd server.
@@ -103,4 +105,28 @@ public class CrowdObjectAccess
}
}
};
/**
* Provides access control for place objects. The default behavior is to
* allow place occupants to subscribe to the place object and to use the
* {@link #DEFAULT} modification policy.
*/
public static AccessController PLACE = new AccessController()
{
// documentation inherited from interface
public boolean allowSubscribe (DObject object, Subscriber sub)
{
if (sub instanceof CrowdClient) {
ClientObject co = ((CrowdClient)sub).getClientObject();
return ((PlaceObject)object).occupants.contains(co.getOid());
}
return true;
}
// documentation inherited from interface
public boolean allowDispatch (DObject object, DEvent event)
{
return DEFAULT.allowDispatch(object, event);
}
};
}