Obtain our ActionScript dependencies from Maven as well, and publish our swc
artifacts thereto. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6289 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2010 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://code.google.com/p/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.crowd.data {
|
||||
|
||||
import com.threerings.crowd.client.BodyService;
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.data.InvocationMarshaller;
|
||||
import com.threerings.util.langBoolean;
|
||||
|
||||
/**
|
||||
* Provides the implementation of the <code>BodyService</code> interface
|
||||
* that marshalls the arguments and delivers the request to the provider
|
||||
* on the server. Also provides an implementation of the response listener
|
||||
* interfaces that marshall the response arguments and deliver them back
|
||||
* to the requesting client.
|
||||
*/
|
||||
public class BodyMarshaller extends InvocationMarshaller
|
||||
implements BodyService
|
||||
{
|
||||
/** The method id used to dispatch <code>setIdle</code> requests. */
|
||||
public static const SET_IDLE :int = 1;
|
||||
|
||||
// from interface BodyService
|
||||
public function setIdle (arg1 :Boolean) :void
|
||||
{
|
||||
sendRequest(SET_IDLE, [
|
||||
langBoolean.valueOf(arg1)
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2010 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://code.google.com/p/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.crowd.data {
|
||||
|
||||
import com.threerings.util.Byte;
|
||||
import com.threerings.util.Name;
|
||||
|
||||
import com.threerings.presents.data.ClientObject;
|
||||
import com.threerings.presents.data.InvocationCodes;
|
||||
|
||||
import com.threerings.crowd.chat.data.ChatCodes;
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
|
||||
/**
|
||||
* The basic user object class for Crowd users. Bodies have a location and a status.
|
||||
*/
|
||||
public class BodyObject extends ClientObject
|
||||
{
|
||||
// AUTO-GENERATED: FIELDS START
|
||||
/** The field name of the <code>location</code> field. */
|
||||
public static const LOCATION :String = "location";
|
||||
|
||||
/** The field name of the <code>status</code> field. */
|
||||
public static const STATUS :String = "status";
|
||||
|
||||
/** The field name of the <code>awayMessage</code> field. */
|
||||
public static const AWAY_MESSAGE :String = "awayMessage";
|
||||
// AUTO-GENERATED: FIELDS END
|
||||
|
||||
/**
|
||||
* The oid of the place currently occupied by this body or -1 if they currently occupy no
|
||||
* place.
|
||||
*/
|
||||
public var location :Place;
|
||||
|
||||
/**
|
||||
* The user's current status ({@link OccupantInfo#ACTIVE}, etc.).
|
||||
*/
|
||||
public var status :int;
|
||||
|
||||
/**
|
||||
* If non-null, this contains a message to be auto-replied whenever another user delivers a
|
||||
* tell message to this user.
|
||||
*/
|
||||
public var awayMessage :String;
|
||||
|
||||
/**
|
||||
* Returns this user's access control tokens.
|
||||
*/
|
||||
public function getTokens () :TokenRing
|
||||
{
|
||||
return new TokenRing();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name that should be displayed to other users. The default is to use
|
||||
* <code>username</code>.
|
||||
* @see com.threerings.presents.data.ClientObject#username
|
||||
*/
|
||||
public function getVisibleName () :Name
|
||||
{
|
||||
return username;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the oid of the place occupied by this body or -1 if we occupy no place.
|
||||
*/
|
||||
public function getPlaceOid () :int
|
||||
{
|
||||
return (location == null) ? -1 : location.placeOid;
|
||||
}
|
||||
|
||||
// // AUTO-GENERATED: METHODS START
|
||||
// /**
|
||||
// * Requests that the <code>username</code> field be set to the
|
||||
// * specified value. The local value will be updated immediately and an
|
||||
// * event will be propagated through the system to notify all listeners
|
||||
// * that the attribute did change. Proxied copies of this object (on
|
||||
// * clients) will apply the value change when they received the
|
||||
// * attribute changed notification.
|
||||
// */
|
||||
// public function setUsername (value :Name) :void
|
||||
// {
|
||||
// var ovalue :Name = this.username;
|
||||
// requestAttributeChange(
|
||||
// USERNAME, value, ovalue);
|
||||
// this.username = value;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Requests that the <code>location</code> field be set to the
|
||||
// * specified value. The local value will be updated immediately and an
|
||||
// * event will be propagated through the system to notify all listeners
|
||||
// * that the attribute did change. Proxied copies of this object (on
|
||||
// * clients) will apply the value change when they received the
|
||||
// * attribute changed notification.
|
||||
// */
|
||||
// public function setLocation (value :int) :void
|
||||
// {
|
||||
// var ovalue :int = this.location;
|
||||
// requestAttributeChange(
|
||||
// LOCATION, value, ovalue);
|
||||
// this.location = value;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Requests that the <code>status</code> field be set to the
|
||||
// * specified value. The local value will be updated immediately and an
|
||||
// * event will be propagated through the system to notify all listeners
|
||||
// * that the attribute did change. Proxied copies of this object (on
|
||||
// * clients) will apply the value change when they received the
|
||||
// * attribute changed notification.
|
||||
// */
|
||||
// public function setStatus (value :int) :void
|
||||
// {
|
||||
// var ovalue :int = this.status;
|
||||
// requestAttributeChange(
|
||||
// STATUS, Byte.valueOf(value), Byte.valueOf(ovalue));
|
||||
// this.status = value;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Requests that the <code>awayMessage</code> field be set to the
|
||||
// * specified value. The local value will be updated immediately and an
|
||||
// * event will be propagated through the system to notify all listeners
|
||||
// * that the attribute did change. Proxied copies of this object (on
|
||||
// * clients) will apply the value change when they received the
|
||||
// * attribute changed notification.
|
||||
// */
|
||||
// public function setAwayMessage (value :String) :void
|
||||
// {
|
||||
// var ovalue :String = this.awayMessage;
|
||||
// requestAttributeChange(
|
||||
// AWAY_MESSAGE, value, ovalue);
|
||||
// this.awayMessage = value;
|
||||
// }
|
||||
// // AUTO-GENERATED: METHODS END
|
||||
//
|
||||
// override public function writeObject (out :ObjectOutputStream) :void
|
||||
// {
|
||||
// super.writeObject(out);
|
||||
//
|
||||
// out.writeObject(username);
|
||||
// out.writeInt(location);
|
||||
// out.writeByte(status);
|
||||
// out.writeField(awayMessage);
|
||||
// }
|
||||
|
||||
override public function who () :String
|
||||
{
|
||||
var who :String = username.toString() + " (" + getOid();
|
||||
if (status != OccupantInfo.ACTIVE) {
|
||||
who += (" " + getStatusTranslation());
|
||||
}
|
||||
who += ")";
|
||||
return who;
|
||||
}
|
||||
|
||||
override public function readObject (ins :ObjectInputStream) :void
|
||||
{
|
||||
super.readObject(ins);
|
||||
location = Place(ins.readObject());
|
||||
status = ins.readByte();
|
||||
awayMessage = (ins.readField(String) as String);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a translation suffix for this occupant's status.
|
||||
* Can be overridden to translate nonstandard statuses.
|
||||
*/
|
||||
protected function getStatusTranslation () :String
|
||||
{
|
||||
return OccupantInfo.X_STATUS[status];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2010 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://code.google.com/p/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.crowd.data {
|
||||
|
||||
import com.threerings.presents.data.InvocationCodes;
|
||||
|
||||
/**
|
||||
* Defines codes and constants global to the Crowd services.
|
||||
*/
|
||||
public class CrowdCodes extends InvocationCodes
|
||||
{
|
||||
/** Defines our invocation services group. */
|
||||
public static const CROWD_GROUP :String = "crowd";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2010 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://code.google.com/p/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.crowd.data {
|
||||
|
||||
import com.threerings.presents.data.ClientObject;
|
||||
import com.threerings.presents.data.InvocationCodes;
|
||||
import com.threerings.presents.data.Permission;
|
||||
import com.threerings.presents.data.PermissionPolicy;
|
||||
|
||||
import com.threerings.crowd.chat.data.ChatCodes;
|
||||
|
||||
/**
|
||||
* Implements some Crowd permissions.
|
||||
*/
|
||||
public class CrowdPermissionPolicy extends PermissionPolicy
|
||||
{
|
||||
// from PermissionPolicy
|
||||
override public function checkAccess (
|
||||
clobj :ClientObject, perm :Permission, context :Object) :String
|
||||
{
|
||||
if (!(clobj is BodyObject)) {
|
||||
return super.checkAccess(clobj, perm, context);
|
||||
}
|
||||
|
||||
var body :BodyObject = (clobj as BodyObject);
|
||||
if (perm == ChatCodes.BROADCAST_ACCESS) {
|
||||
return body.getTokens().isAdmin() ? null : InvocationCodes.ACCESS_DENIED;
|
||||
} else if (perm == ChatCodes.CHAT_ACCESS) {
|
||||
return null;
|
||||
} else {
|
||||
return super.checkAccess(clobj, perm, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2010 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://code.google.com/p/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.crowd.data {
|
||||
|
||||
import com.threerings.presents.data.InvocationCodes;
|
||||
|
||||
/**
|
||||
* Contains codes used by the location invocation services.
|
||||
*/
|
||||
public class LocationCodes extends InvocationCodes
|
||||
{
|
||||
/** An error code indicating that a place identified by a particular
|
||||
* place id does not exist. Usually generated by a failed moveTo
|
||||
* request. */
|
||||
public static const NO_SUCH_PLACE :String = "m.no_such_place";
|
||||
|
||||
/** An error code sent when a user requests to move to a new place but
|
||||
* they are in the middle of moving somewhere already. */
|
||||
public static const MOVE_IN_PROGRESS :String = "m.move_in_progress";
|
||||
|
||||
/** An error code sent when a user requests to move to a place, but
|
||||
* they are already in the requested place. */
|
||||
public static const ALREADY_THERE :String = "m.already_there";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2010 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://code.google.com/p/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.crowd.data {
|
||||
|
||||
import com.threerings.crowd.client.LocationService;
|
||||
import com.threerings.crowd.client.LocationService_MoveListener;
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.data.InvocationMarshaller;
|
||||
import com.threerings.util.Integer;
|
||||
|
||||
/**
|
||||
* Provides the implementation of the <code>LocationService</code> interface
|
||||
* that marshalls the arguments and delivers the request to the provider
|
||||
* on the server. Also provides an implementation of the response listener
|
||||
* interfaces that marshall the response arguments and deliver them back
|
||||
* to the requesting client.
|
||||
*/
|
||||
public class LocationMarshaller extends InvocationMarshaller
|
||||
implements LocationService
|
||||
{
|
||||
/** The method id used to dispatch <code>leavePlace</code> requests. */
|
||||
public static const LEAVE_PLACE :int = 1;
|
||||
|
||||
// from interface LocationService
|
||||
public function leavePlace () :void
|
||||
{
|
||||
sendRequest(LEAVE_PLACE, [
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
/** The method id used to dispatch <code>moveTo</code> requests. */
|
||||
public static const MOVE_TO :int = 2;
|
||||
|
||||
// from interface LocationService
|
||||
public function moveTo (arg1 :int, arg2 :LocationService_MoveListener) :void
|
||||
{
|
||||
var listener2 :LocationMarshaller_MoveMarshaller = new LocationMarshaller_MoveMarshaller();
|
||||
listener2.listener = arg2;
|
||||
sendRequest(MOVE_TO, [
|
||||
Integer.valueOf(arg1), listener2
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2010 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://code.google.com/p/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.crowd.data {
|
||||
|
||||
import com.threerings.crowd.client.LocationService_MoveListener;
|
||||
import com.threerings.presents.data.InvocationMarshaller_ListenerMarshaller;
|
||||
|
||||
/**
|
||||
* Marshalls instances of the LocationService_MoveMarshaller interface.
|
||||
*/
|
||||
public class LocationMarshaller_MoveMarshaller
|
||||
extends InvocationMarshaller_ListenerMarshaller
|
||||
{
|
||||
/** The method id used to dispatch <code>moveSucceeded</code> responses. */
|
||||
public static const MOVE_SUCCEEDED :int = 1;
|
||||
|
||||
// from InvocationMarshaller_ListenerMarshaller
|
||||
override public function dispatchResponse (methodId :int, args :Array) :void
|
||||
{
|
||||
switch (methodId) {
|
||||
case MOVE_SUCCEEDED:
|
||||
(listener as LocationService_MoveListener).moveSucceeded(
|
||||
(args[0] as PlaceConfig));
|
||||
return;
|
||||
|
||||
default:
|
||||
super.dispatchResponse(methodId, args);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2010 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://code.google.com/p/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.crowd.data {
|
||||
|
||||
import com.threerings.presents.dobj.ServerMessageEvent;
|
||||
|
||||
public class ManagerCaller
|
||||
{
|
||||
public function ManagerCaller (plobj :PlaceObject)
|
||||
{
|
||||
_plobj = plobj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to call a method on the manager.
|
||||
*/
|
||||
public function invoke (method :String, ... args) :void
|
||||
{
|
||||
_plobj.postEvent(new ServerMessageEvent(_plobj.getOid(), method, args));
|
||||
}
|
||||
|
||||
/** The place object we're thingy-ing for. */
|
||||
protected var _plobj :PlaceObject;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2010 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://code.google.com/p/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.crowd.data {
|
||||
|
||||
import flash.system.ApplicationDomain;
|
||||
|
||||
import com.threerings.util.ClassUtil;
|
||||
import com.threerings.util.Cloneable;
|
||||
import com.threerings.util.Integer;
|
||||
import com.threerings.util.Name;
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
import com.threerings.io.SimpleStreamableObject;
|
||||
|
||||
import com.threerings.presents.dobj.DSet_Entry;
|
||||
|
||||
import com.threerings.crowd.data.BodyObject;
|
||||
|
||||
/**
|
||||
* The occupant info object contains all of the information about an
|
||||
* occupant of a place that should be shared with other occupants of the
|
||||
* place. These objects are stored in the place object itself and are
|
||||
* updated when bodies enter and exit a place.
|
||||
*
|
||||
* <p> A system that builds upon the Crowd framework can extend this class to
|
||||
* include extra information about their occupants. They will need to provide a
|
||||
* derived {@link BodyObject} that creates and configures their occupant info
|
||||
* in {@link BodyObject#createOccupantInfo}.
|
||||
*
|
||||
* <p> Note also that this class implements {@link Cloneable} which means
|
||||
* that if derived classes add non-primitive attributes, they are
|
||||
* responsible for adding the code to clone those attributes when a clone
|
||||
* is requested.
|
||||
*/
|
||||
public class OccupantInfo extends SimpleStreamableObject
|
||||
implements DSet_Entry, Cloneable
|
||||
{
|
||||
/** Constant value for {@link #status}. */
|
||||
public static const ACTIVE :int = 0;
|
||||
|
||||
/** Constant value for {@link #status}. */
|
||||
public static const IDLE :int = 1;
|
||||
|
||||
/** Constant value for {@link #status}. */
|
||||
public static const DISCONNECTED :int = 2;
|
||||
|
||||
/** Maps status codes to human readable strings. */
|
||||
public static const X_STATUS :Array = [ "active", "idle", "discon" ];
|
||||
|
||||
/** The body object id of this occupant (and our entry key). */
|
||||
public var bodyOid :int;
|
||||
|
||||
/** The username of this occupant. */
|
||||
public var username :Name;
|
||||
|
||||
/** The status of this occupant. */
|
||||
public var status :int = ACTIVE;
|
||||
|
||||
/**
|
||||
* Constructs an occupant info record, optionally obtaining data from the
|
||||
* supplied BodyObject.
|
||||
*/
|
||||
public function OccupantInfo (body :BodyObject = null)
|
||||
{
|
||||
if (body != null) {
|
||||
bodyOid = body.getOid();
|
||||
username = body.getVisibleName();
|
||||
status = body.status;
|
||||
}
|
||||
}
|
||||
|
||||
/** Access to the body object id as an int. */
|
||||
public function getBodyOid () :int
|
||||
{
|
||||
return bodyOid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a cloned copy of this instance.
|
||||
*/
|
||||
public function clone () :Object
|
||||
{
|
||||
var that :OccupantInfo = ClassUtil.newInstance(this) as OccupantInfo;
|
||||
that.bodyOid = this.bodyOid;
|
||||
that.username = this.username;
|
||||
that.status = this.status;
|
||||
return that;
|
||||
}
|
||||
|
||||
// documentation inherited from interface DSet_Entry
|
||||
public function getKey () :Object
|
||||
{
|
||||
return bodyOid;
|
||||
}
|
||||
|
||||
// from interface Streamable
|
||||
override public function readObject (ins :ObjectInputStream) :void
|
||||
{
|
||||
super.readObject(ins);
|
||||
bodyOid = (ins.readField(Integer) as Integer).value;
|
||||
username = Name(ins.readObject());
|
||||
status = ins.readByte();
|
||||
}
|
||||
|
||||
// from interface Streamable
|
||||
override public function writeObject (out :ObjectOutputStream) :void
|
||||
{
|
||||
super.writeObject(out);
|
||||
out.writeObject(new Integer(bodyOid));
|
||||
out.writeObject(username);
|
||||
out.writeByte(status);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2010 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://code.google.com/p/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.crowd.data {
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
import com.threerings.io.SimpleStreamableObject;
|
||||
import com.threerings.util.Hashable;
|
||||
|
||||
/**
|
||||
* Contains information on the current place occupied by a body.
|
||||
*/
|
||||
public class Place extends SimpleStreamableObject
|
||||
implements Hashable
|
||||
{
|
||||
/** The oid of this place's {@link PlaceObject}. */
|
||||
public var placeOid :int;
|
||||
|
||||
/**
|
||||
* Creates a place with the supplied oid.
|
||||
*/
|
||||
public function Place (placeOid :int = 0)
|
||||
{
|
||||
this.placeOid = placeOid;
|
||||
}
|
||||
|
||||
// from Object
|
||||
public function hashCode () :int
|
||||
{
|
||||
return placeOid;
|
||||
}
|
||||
|
||||
// from Object
|
||||
public function equals (other :Object) :Boolean
|
||||
{
|
||||
return (other is Place) && ((other as Place).placeOid == placeOid);
|
||||
}
|
||||
|
||||
// from interface Streamable
|
||||
override public function readObject (ins :ObjectInputStream) :void
|
||||
{
|
||||
super.readObject(ins);
|
||||
placeOid = ins.readInt();
|
||||
}
|
||||
|
||||
// from interface Streamable
|
||||
override public function writeObject (out :ObjectOutputStream) :void
|
||||
{
|
||||
super.writeObject(out);
|
||||
out.writeInt(placeOid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2010 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://code.google.com/p/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.crowd.data {
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
import com.threerings.io.SimpleStreamableObject;
|
||||
|
||||
import com.threerings.crowd.client.PlaceController;
|
||||
|
||||
/**
|
||||
* The place config class encapsulates the configuration information for a
|
||||
* particular type of place. The hierarchy of place config objects mimics
|
||||
* the hierarchy of place managers and controllers. Both the place manager
|
||||
* and place controller are provided with the place config object when the
|
||||
* place is created.
|
||||
*
|
||||
* <p> The place config object is also the mechanism used to instantiate
|
||||
* the appropriate place manager and controller. Every place must have an
|
||||
* associated place config derived class that overrides {@link
|
||||
* #getControllerClass} and {@link #getManagerClassName}, returning the
|
||||
* appropriate place controller and manager class for that place.
|
||||
*/
|
||||
public /*abstract*/ class PlaceConfig extends SimpleStreamableObject
|
||||
{
|
||||
public function PlaceConfig ()
|
||||
{
|
||||
// nothing needed
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the class that should be used to create a controller for this
|
||||
* place. The controller class must derive from {@link PlaceController}.
|
||||
*
|
||||
* @deprecated Override {@link #createController} directly.
|
||||
*/
|
||||
public function getControllerClass () :Class
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the controller that should be used for this place.
|
||||
*/
|
||||
public function createController () :PlaceController
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the class that should be used to create a
|
||||
* manager for this place. The manager class must derive from {@link
|
||||
* com.threerings.crowd.server.PlaceManager}. <em>Note:</em> this
|
||||
* method differs from {@link #getControllerClass} because we want to
|
||||
* avoid compile time linkage of the place config object (which is
|
||||
* used on the client) to server code. This allows a code optimizer
|
||||
* (DashO Pro, for example) to remove the server code from the client,
|
||||
* knowing that it is never used.
|
||||
*/
|
||||
public function getManagerClassName () :String
|
||||
{
|
||||
return null; // not used
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2010 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://code.google.com/p/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.crowd.data {
|
||||
|
||||
import com.threerings.util.Iterator;
|
||||
import com.threerings.util.Name;
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
|
||||
import com.threerings.presents.dobj.DObject;
|
||||
import com.threerings.presents.dobj.DSet;
|
||||
import com.threerings.presents.dobj.OidList;
|
||||
|
||||
import com.threerings.crowd.chat.data.SpeakMarshaller;
|
||||
//import com.threerings.crowd.chat.data.SpeakObject;
|
||||
|
||||
/**
|
||||
* A distributed object that contains information on a place that is
|
||||
* occupied by bodies. This place might be a chat room, a game room, an
|
||||
* island in a massively multiplayer piratical universe, anything that has
|
||||
* occupants that might want to chat with one another.
|
||||
*/
|
||||
public class PlaceObject extends DObject
|
||||
{
|
||||
// AUTO-GENERATED: FIELDS START
|
||||
/** The field name of the <code>occupants</code> field. */
|
||||
public static const OCCUPANTS :String = "occupants";
|
||||
|
||||
/** The field name of the <code>occupantInfo</code> field. */
|
||||
public static const OCCUPANT_INFO :String = "occupantInfo";
|
||||
|
||||
/** The field name of the <code>speakService</code> field. */
|
||||
public static const SPEAK_SERVICE :String = "speakService";
|
||||
// AUTO-GENERATED: FIELDS END
|
||||
|
||||
/**
|
||||
* Allows the client to call methods on the manager.
|
||||
*/
|
||||
public var manager :ManagerCaller;
|
||||
|
||||
/**
|
||||
* Tracks the oid of the body objects of all of the occupants of this
|
||||
* place.
|
||||
*/
|
||||
public var occupants :OidList = new OidList();
|
||||
|
||||
/**
|
||||
* Contains an info record (of type {@link OccupantInfo}) for each
|
||||
* occupant that contains information about that occupant that needs
|
||||
* to be known by everyone in the place. <em>Note:</em> Don't obtain
|
||||
* occupant info records directly from this set when on the server,
|
||||
* use <code>PlaceManager.getOccupantInfo()</code> instead (along with
|
||||
* <code>PlaceManager.updateOccupantInfo()</code>) because it does
|
||||
* some special processing to ensure that readers and updaters don't
|
||||
* step on one another even if they make rapid fire changes to a
|
||||
* user's occupant info.
|
||||
*/
|
||||
public var occupantInfo :DSet = new DSet();
|
||||
|
||||
/** Used to generate speak requests on this place object. */
|
||||
public var speakService :SpeakMarshaller;
|
||||
|
||||
/**
|
||||
* We need a constructor here in actionscript to set up the
|
||||
* ManagerCaller.
|
||||
*/
|
||||
public function PlaceObject ()
|
||||
{
|
||||
super();
|
||||
manager = new ManagerCaller(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks up a user's occupant info by name.
|
||||
*
|
||||
* @return the occupant info record for the named user or null if no
|
||||
* user in the room has that username.
|
||||
*/
|
||||
public function getOccupantInfo (username :Name) :OccupantInfo
|
||||
{
|
||||
var itr :Iterator = occupantInfo.iterator();
|
||||
while (itr.hasNext()) {
|
||||
var info :OccupantInfo = (itr.next() as OccupantInfo);
|
||||
if (info.username.equals(username)) {
|
||||
return info;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// // AUTO-GENERATED: METHODS START
|
||||
// /**
|
||||
// * Requests that <code>oid</code> be added to the <code>occupants</code>
|
||||
// * oid list. The list will not change until the event is actually
|
||||
// * propagated through the system.
|
||||
// */
|
||||
// public function addToOccupants (oid :int) :void
|
||||
// {
|
||||
// requestOidAdd(OCCUPANTS, oid);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Requests that <code>oid</code> be removed from the
|
||||
// * <code>occupants</code> oid list. The list will not change until the
|
||||
// * event is actually propagated through the system.
|
||||
// */
|
||||
// public function removeFromOccupants (oid :int) :void
|
||||
// {
|
||||
// requestOidRemove(OCCUPANTS, oid);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Requests that the specified entry be added to the
|
||||
// * <code>occupantInfo</code> set. The set will not change until the event is
|
||||
// * actually propagated through the system.
|
||||
// */
|
||||
// public function addToOccupantInfo (elem :DSet_Entry) :void
|
||||
// {
|
||||
// requestEntryAdd(OCCUPANT_INFO, elem);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Requests that the entry matching the supplied key be removed from
|
||||
// * the <code>occupantInfo</code> set. The set will not change until the
|
||||
// * event is actually propagated through the system.
|
||||
// */
|
||||
// public function removeFromOccupantInfo (key :Object) :void
|
||||
// {
|
||||
// requestEntryRemove(OCCUPANT_INFO, key);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Requests that the specified entry be updated in the
|
||||
// * <code>occupantInfo</code> set. The set will not change until the event is
|
||||
// * actually propagated through the system.
|
||||
// */
|
||||
// public function updateOccupantInfo (elem :DSet_Entry) :void
|
||||
// {
|
||||
// requestEntryUpdate(OCCUPANT_INFO, elem);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Requests that the <code>occupantInfo</code> field be set to the
|
||||
// * specified value. Generally one only adds, updates and removes
|
||||
// * entries of a distributed set, but certain situations call for a
|
||||
// * complete replacement of the set value. The local value will be
|
||||
// * updated immediately and an event will be propagated through the
|
||||
// * system to notify all listeners that the attribute did
|
||||
// * change. Proxied copies of this object (on clients) will apply the
|
||||
// * value change when they received the attribute changed notification.
|
||||
// */
|
||||
// public function setOccupantInfo (value :DSet) :void
|
||||
// {
|
||||
// requestAttributeChange(OCCUPANT_INFO, value, this.occupantInfo);
|
||||
// this.occupantInfo = (value == null) ? null : value;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Requests that the <code>speakService</code> field be set to the
|
||||
// * specified value. The local value will be updated immediately and an
|
||||
// * event will be propagated through the system to notify all listeners
|
||||
// * that the attribute did change. Proxied copies of this object (on
|
||||
// * clients) will apply the value change when they received the
|
||||
// * attribute changed notification.
|
||||
// */
|
||||
// public function setSpeakService (value :SpeakMarshaller) :void
|
||||
// {
|
||||
// var ovalue :SpeakMarshaller = this.speakService;
|
||||
// requestAttributeChange(
|
||||
// SPEAK_SERVICE, value, ovalue);
|
||||
// this.speakService = value;
|
||||
// }
|
||||
// // AUTO-GENERATED: METHODS END
|
||||
//
|
||||
// // documentation inherited
|
||||
// override public function writeObject (out :ObjectOutputStream) :void
|
||||
// {
|
||||
// super.writeObject(out);
|
||||
// out.writeObject(occupants);
|
||||
// out.writeObject(occupantInfo);
|
||||
// out.writeObject(speakService);
|
||||
// }
|
||||
|
||||
// documentation inherited
|
||||
override public function readObject (ins :ObjectInputStream) :void
|
||||
{
|
||||
super.readObject(ins);
|
||||
occupants = OidList(ins.readObject());
|
||||
occupantInfo = DSet(ins.readObject());
|
||||
speakService = SpeakMarshaller(ins.readObject());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2010 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://code.google.com/p/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.crowd.data {
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
import com.threerings.io.SimpleStreamableObject;
|
||||
|
||||
/**
|
||||
* Defines access control tokens that convey certain privileges to users
|
||||
* (see {@link BodyObject#checkAccess}).
|
||||
*/
|
||||
public class TokenRing extends SimpleStreamableObject
|
||||
{
|
||||
/** Indicates that this user is an administrator and can do things like broadcast, shutdown the
|
||||
* server and whatnot. */
|
||||
public static const ADMIN :int = (1 << 0);
|
||||
|
||||
/**
|
||||
* Constructs a token ring with the supplied set of tokens.
|
||||
*/
|
||||
public function TokenRing (tokens :int = 0)
|
||||
{
|
||||
_tokens = tokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the specified token to this ring.
|
||||
*/
|
||||
public function setToken (token :int, setOn :Boolean = true) :void
|
||||
{
|
||||
if (setOn) {
|
||||
_tokens |= token;
|
||||
|
||||
} else {
|
||||
clearToken(token);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bitmask that stores the various tokens.
|
||||
*/
|
||||
public function getTokens () :int
|
||||
{
|
||||
return _tokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience function for checking whether this ring holds the
|
||||
* {@link #ADMIN} token.
|
||||
*/
|
||||
public function isAdmin () :Boolean
|
||||
{
|
||||
return holdsToken(ADMIN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this token ring contains the specified token or tokens,
|
||||
* exactly.
|
||||
* For example, if you pass in the OR of two or more tokens,
|
||||
* then the ring must contain all of those tokens.
|
||||
*/
|
||||
public function holdsToken (token :int) :Boolean
|
||||
{
|
||||
return (_tokens & token) == token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this token ring contains any one of the specified tokens.
|
||||
*/
|
||||
public function holdsAnyToken (tokens :int) :Boolean
|
||||
{
|
||||
return (_tokens & tokens) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the specified token from this ring.
|
||||
*/
|
||||
public function clearToken (token :int) :void
|
||||
{
|
||||
_tokens &= ~token;
|
||||
}
|
||||
|
||||
// from interface Streamable
|
||||
override public function readObject (ins :ObjectInputStream) :void
|
||||
{
|
||||
super.readObject(ins);
|
||||
_tokens = ins.readInt();
|
||||
}
|
||||
|
||||
// from interface Streamable
|
||||
override public function writeObject (out :ObjectOutputStream) :void
|
||||
{
|
||||
super.writeObject(out);
|
||||
out.writeInt(_tokens);
|
||||
}
|
||||
|
||||
/** The tokens contained in this ring (composed together bitwise). */
|
||||
protected var _tokens :int;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user