Revamped the way BodyObject.location is tracked. Now we use an object which can

be extended to contain the sceneId by Whirled (Vilya's Whirled, though also
Whirled Whirled by extension) so that we don't end up with problems where
BodyObject.location changes but BodyObject.sceneId remains stale. This won't
impact Yohoho because the Yohoho client is always in a scene, it uses a
separate mechanism to track games, whereas Whirled's natural usage is to move
between scenes and non-scenes.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4779 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2007-07-21 00:46:25 +00:00
parent 9ef330b291
commit 962326fcaf
16 changed files with 332 additions and 205 deletions
@@ -24,7 +24,6 @@ package com.threerings.crowd.chat.data {
import flash.utils.getTimer; // function import
import com.threerings.util.ClassUtil;
import com.threerings.util.Long;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
@@ -42,8 +41,8 @@ public /*abstract*/ class ChatMessage
/** The bundle to use when translating this message. */
public var bundle :String;
/** The client side 'localtype' of this chat, set to the type
* registered with an auxiliary source in the ChatDirector. */
/** The client side 'localtype' of this chat, set to the type registered with an auxiliary
* source in the ChatDirector. */
public var localtype :String;
/** The client time that this message was created. */
@@ -67,14 +66,6 @@ public /*abstract*/ class ChatMessage
timestamp = getTimer();
}
/**
* Get the appropriate message format for this message.
*/
public function getFormat () :String
{
return null;
}
/**
* Generates a string representation of this instance.
*/
@@ -84,6 +75,14 @@ public /*abstract*/ class ChatMessage
" [message=" + message + ", bundle=" + bundle + "]";
}
/**
* Get the appropriate message format for this message.
*/
public function getFormat () :String
{
return null;
}
// from interface Streamable
public function readObject (ins :ObjectInputStream) :void
{
@@ -30,19 +30,16 @@ import com.threerings.io.ObjectOutputStream;
*/
public class SystemMessage extends ChatMessage
{
/** Attention level constant to indicate that this message is merely
* providing the user with information. */
/** Attention level constant to indicate that this message is merely providing the user with
* information. */
public static const INFO :int = 0;
/** Attention level constant to indicate that this message is the
* result of a user action. */
/** Attention level constant to indicate that this message is the result of a user action. */
public static const FEEDBACK :int = 1;
/** Attention level constant to indicate that some action is required. */
public static const ATTENTION :int = 2;
//----
/** The attention level of this message. */
public var attentionLevel :int;
@@ -21,6 +21,8 @@
package com.threerings.crowd.chat.data {
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
import com.threerings.util.Name;
/**
@@ -34,7 +36,7 @@ public class TellFeedbackMessage extends UserMessage
public function TellFeedbackMessage (target :Name, message :String, failed :Boolean = false)
{
super(target, null, message);
_failed = failed;
_failure = failed;
}
/**
@@ -42,14 +44,28 @@ public class TellFeedbackMessage extends UserMessage
*/
public function isFailure () :Boolean
{
return _failed;
return _failure;
}
override public function getFormat () :String
{
return _failed ? null : "m.told_format";
return _failure ? null : "m.told_format";
}
protected var _failed :Boolean;
// from interface Streamable
override public function readObject (ins :ObjectInputStream) :void
{
super.readObject(ins);
_failure = ins.readBoolean();
}
// from interface Streamable
override public function writeObject (out :ObjectOutputStream) :void
{
super.writeObject(out);
out.writeBoolean(_failure);
}
protected var _failure :Boolean;
}
}
@@ -33,8 +33,7 @@ import com.threerings.io.ObjectOutputStream;
*/
public class UserSystemMessage extends SystemMessage
{
/** The "speaker" of this message, the user that triggered that this
* message be sent to us. */
/** The "speaker" of this message, the user that triggered that this message be sent to us. */
public var speaker :Name;
/**
@@ -48,6 +47,7 @@ public class UserSystemMessage extends SystemMessage
this.speaker = sender;
}
// from interface Streamable
override public function readObject (ins :ObjectInputStream) :void
{
super.readObject(ins);
+23 -18
View File
@@ -33,8 +33,7 @@ import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
/**
* The basic user object class for Crowd users. Bodies have a username, a
* location and a status.
* The basic user object class for Crowd users. Bodies have a username, a location and a status.
*/
public class BodyObject extends ClientObject
{
@@ -53,17 +52,17 @@ public class BodyObject extends ClientObject
// AUTO-GENERATED: FIELDS END
/**
* The username associated with this body object. This should not be used
* directly; in general {@link #getVisibleName} should be used unless you
* specifically know that you want the username.
* The username associated with this body object. This should not be used directly; in general
* {@link #getVisibleName} should be used unless you specifically know that you want the
* username.
*/
public var username :Name;
/**
* The oid of the place currently occupied by this body or -1 if they
* currently occupy no place.
* The oid of the place currently occupied by this body or -1 if they currently occupy no
* place.
*/
public var location :int = -1;
public var location :Place;
/**
* The user's current status ({@link OccupantInfo#ACTIVE}, etc.).
@@ -71,21 +70,19 @@ public class BodyObject extends ClientObject
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.
* 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;
/**
* Checks whether or not this user has access to the specified
* feature. Currently used by the chat system to regulate access to
* chat broadcasts but also forms the basis of an extensible
* Checks whether or not this user has access to the specified feature. Currently used by the
* chat system to regulate access to chat broadcasts but also forms the basis of an extensible
* fine-grained permissions system.
*
* @return null if the user has access, a fully-qualified translatable
* message string indicating the reason for denial of access (or just
* {@link InvocationCodes#ACCESS_DENIED} if you don't want to be
* specific).
* @return null if the user has access, a fully-qualified translatable message string
* indicating the reason for denial of access (or just {@link InvocationCodes#ACCESS_DENIED} if
* you don't want to be specific).
*/
public function checkAccess (feature :String, context :Object) :String
{
@@ -116,6 +113,14 @@ public class BodyObject extends ClientObject
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
@@ -207,7 +212,7 @@ public class BodyObject extends ClientObject
super.readObject(ins);
username = (ins.readObject() as Name);
location = ins.readInt();
location = (ins.readObject() as Place);
status = ins.readByte();
awayMessage = (ins.readField(String) as String);
}
@@ -118,11 +118,10 @@ public class OccupantInfo extends SimpleStreamableObject
// from interface Streamable
override public function writeObject (out :ObjectOutputStream) :void
{
throw new Error();
// super.writeObject(out);
// out.writeObject(new Integer(bodyOid));
// out.writeObject(username);
// out.writeByte(status);
super.writeObject(out);
out.writeObject(new Integer(bodyOid));
out.writeObject(username);
out.writeByte(status);
}
}
}
+64
View File
@@ -0,0 +1,64 @@
//
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2007 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/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;
/**
* Contains information on the current place occupied by a body.
*/
public class Place extends SimpleStreamableObject
{
/** 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 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);
}
}
}
@@ -31,8 +31,8 @@ import com.threerings.io.SimpleStreamableObject;
*/
public class TokenRing extends SimpleStreamableObject
{
/** Indicates that this user is an administrator and can do things
* like broadcast, shutdown the server and whatnot. */
/** 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);
/**
@@ -34,20 +34,18 @@ import com.threerings.util.Long;
public class ConMgrStats extends SimpleStreamableObject
implements Cloneable
{
/** The size of the queue of waiting to auth sockets. This is a snapshot at
* the time the stats are requested. */
/** The size of the queue of waiting to auth sockets. This is a snapshot at the time the stats
* are requested. */
public var authQueueSize :int;
/** The size of the queue of waiting to die sockets. This is a snapshot at
* the time the stats are requested. */
/** The size of the queue of waiting to die sockets. This is a snapshot at the time the stats
* are requested. */
public var deathQueueSize :int;
/** The outgoing queue size. This is a snapshot at the time the stats are
* requested. */
/** The outgoing queue size. This is a snapshot at the time the stats are requested. */
public var outQueueSize :int;
/** The overflow queue size. This is a snapshot at the time the stats are
* requested. */
/** The overflow queue size. This is a snapshot at the time the stats are requested. */
public var overQueueSize :int;
/** The number of connection events since the server started up. */