Checkpoint. This is not compiling right now due to three annoying problems:

- There seems to be a compiler bug that causes classes to be
  imported spuriously, or something. Classes that import only one of the Log
  classes are complaining about visibility of more than one of them.
- static constants are not inherited by subclasses, which is super annoying.
  I will try switching to prototype consts, but there seems to be a problem
  initializing those, and we don't want to make them vars...
- The fact that there are no inner classes combined with no method overloading
  is making things very inconvenient. I've been experimenting with faking
  an anonymous class by instantiating a dynamic object and attaching
  functions to it, but it's not working. I'll continue experimenting, because
  if we can't do this then someone shoot me.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3957 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-03-17 02:19:53 +00:00
parent d1b997b9ff
commit 091c7d2401
22 changed files with 283 additions and 123 deletions
@@ -29,6 +29,8 @@ import com.threerings.util.SimpleMap;
import com.threerings.presents.client.BasicDirector;
import com.threerings.presents.client.Client;
import com.threerings.presents.client.ClientEvent;
import com.threerings.presents.client.InvocationAdapter;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.dobj.DObject;
import com.threerings.presents.dobj.MessageEvent;
@@ -249,7 +251,7 @@ public class ChatDirector extends BasicDirector
public function displayFeedback (bundle :String, message :String) :void
{
displaySystem(
bundle, message, SystemMessage.FEEDBACK, PLACE_CHAT_TYPE);
bundle, message, SystemMessage.FEEDBACK, ChatCodes.PLACE_CHAT_TYPE);
}
/**
@@ -262,7 +264,7 @@ public class ChatDirector extends BasicDirector
public function displayAttention (bundle :String, message :String) :void
{
displaySystem(
bundle, message, SystemMessage.ATTENTION, PLACE_CHAT_TYPE);
bundle, message, SystemMessage.ATTENTION, ChatCodes.PLACE_CHAT_TYPE);
}
/**
@@ -458,15 +460,15 @@ public class ChatDirector extends BasicDirector
}
// if they are idle, report that
if (idletime > 0) {
// adjust by the time it took them to become idle
idletime += _cctx.getConfig().getValue(
IDLE_TIME_KEY, DEFAULT_IDLE_TIME);
var msg :String = MessageBundle.compose(
"m.recipient_idle", MessageBundle.taint(target),
TimeUtil.getTimeOrderString(idletime, TimeUtil.MINUTE));
displayFeedback(_bundle, msg);
}
// if (idletime > 0) {
// // adjust by the time it took them to become idle
// idletime += _cctx.getConfig().getValue(
// IDLE_TIME_KEY, DEFAULT_IDLE_TIME);
// var msg :String = MessageBundle.compose(
// "m.recipient_idle", MessageBundle.taint(target),
// TimeUtil.getTimeOrderString(idletime, TimeUtil.MINUTE));
// displayFeedback(_bundle, msg);
// }
};
_cservice.tell(_cctx.getClient(), target, message,
@@ -622,32 +624,32 @@ public class ChatDirector extends BasicDirector
}
// documentation inherited
public override function clientDidLogon (client :Client) :void
public override function clientDidLogon (event :ClientEvent) :void
{
super.clientDidLogon(client);
super.clientDidLogon(event);
// listen on the client object for tells
addAuxiliarySource(_clobj = client.getClientObject(),
addAuxiliarySource(_clobj = event.getClient().getClientObject(),
ChatCodes.USER_CHAT_TYPE);
}
// documentation inherited
public override function clientObjectDidChange (client :Client) :void
public override function clientObjectDidChange (event :ClientEvent) :void
{
super.clientObjectDidChange(client);
super.clientObjectDidChange(event);
// change what we're listening to for tells
removeAuxiliarySource(_clobj);
addAuxiliarySource(_clobj = client.getClientObject(),
addAuxiliarySource(_clobj = event.getClient().getClientObject(),
ChatCodes.USER_CHAT_TYPE);
clearDisplays();
}
// documentation inherited
public override function clientDidLogoff (client :Client) :void
public override function clientDidLogoff (event :ClientEvent) :void
{
super.clientDidLogoff(client);
super.clientDidLogoff(event);
// stop listening to it for tells
if (_clobj != null) {
@@ -702,7 +704,7 @@ public class ChatDirector extends BasicDirector
// mogrification may result in something being turned into a slash
// command, in which case we have to run everything through again
// from the start
if (message.startsWith("/")) {
if (message.indexOf("/") == 0) {
return requestChat(speakSvc, message, false);
}
@@ -818,7 +820,7 @@ public class ChatDirector extends BasicDirector
{
var bundle :MessageBundle = _msgmgr.getBundle(_bundle);
if (!bundle.exists(key)) {
return buf;
return text;
}
var repls :Array = bundle.get(key).split("#");
// apply the replacements to each mogrification that matches
@@ -835,7 +837,7 @@ public class ChatDirector extends BasicDirector
* specified command (i.e. the specified command is a prefix of their
* registered command string).
*/
protected function getCommandHandlers (command :String) :SimpleMap
internal function getCommandHandlers (command :String) :SimpleMap
{
var matches :SimpleMap = new SimpleMap();
var user :BodyObject =
@@ -1,5 +1,7 @@
package com.threerings.crowd.chat.client {
import com.threerings.crowd.chat.data.ChatCodes;
public class ClearHandler extends CommandHandler
{
public function ClearHandler (chatdir :ChatDirector)
@@ -1,6 +1,7 @@
package com.threerings.crowd.chat.client {
import com.threerings.util.MessageBundle;
import com.threerings.util.SimpleMap;
import com.threerings.util.StringUtil;
import com.threerings.crowd.chat.data.ChatCodes;
@@ -29,7 +30,7 @@ public class HelpHandler extends CommandHandler
// let the user give commands with or without the /
if (hcmd.charAt(0) == "/") {
hcmd = hcm.substring(1);
hcmd = hcmd.substring(1);
}
// handle "/help help" and "/help boguscmd"
@@ -21,7 +21,7 @@
package com.threerings.crowd.chat.data {
import com.samskivert.util.StringUtil;
import com.threerings.util.ClassUtil;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
@@ -43,6 +43,12 @@ public /*abstract*/ class ChatMessage
* registered with an auxiliary source in the ChatDirector. */
public var localtype :String;
public function ChatMessage (msg :String = null, bundle :String = null)
{
this.message = msg;
this.bundle = bundle;
}
/**
* Once this message reaches the client, the information contained within
* is changed around a bit.
@@ -67,8 +73,8 @@ public /*abstract*/ class ChatMessage
// documentation inherited from interface Streamable
public function readObject (ins :ObjectInputStream) :void
{
message = ins.readField(String);
bundle = ins.readField(String);
message = (ins.readField(String) as String);
bundle = (ins.readField(String) as String);
}
// documentation inherited from interface Streamable
@@ -41,11 +41,16 @@ public class SystemMessage extends ChatMessage
/** 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;
public function SystemMessage (
msg :String = null, bundle :String = null, attLevel :int = 0)
{
super(msg, bundle);
this.attentionLevel = attLevel;
}
public override function readObject (ins :ObjectInputStream) :void
{
super.readObject(ins);
@@ -0,0 +1,38 @@
//
// $Id: TellFeedbackMessage.java 3098 2004-08-27 02:12:55Z mdb $
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 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.chat.data {
/**
* A feedback message to indicate that a tell succeeded.
*/
public class TellFeedbackMessage extends ChatMessage
{
/**
* A tell feedback message is only composed on the client.
*/
public function TellFeedbackMessage (message :String)
{
super(message, null);
setClientInfo(message, ChatCodes.PLACE_CHAT_TYPE);
}
}
}
@@ -0,0 +1,45 @@
//
// $Id$
package com.threerings.crowd.chat.data {
import com.threerings.util.Name;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
/**
* A system message triggered by the activity of another user.
* If the user is muted we can suppress this message, unlike a normal
* system message.
*/
public class UserSystemMessage extends SystemMessage
{
/** The "speaker" of this message, the user that triggered that this
* message be sent to us. */
public var speaker :Name;
/**
* Construct a UserSystemMessage.
*/
public function UserSystemMessage (
sender :Name = null, message :String = null, bundle :String = null,
attLevel :int = 0)
{
super(message, bundle, attLevel);
this.speaker = sender;
}
public override function readObject (ins :ObjectInputStream) :void
{
super.readObject(ins);
speaker = (ins.readObject() as Name);
}
public override function writeObject (out :ObjectOutputStream) :void
{
super.writeObject(out);
out.writeObject(speaker);
}
}
}
@@ -21,13 +21,12 @@
package com.threerings.crowd.client {
// TODO: class is in progress of conversion
import com.threerings.util.ObserverList;
import com.threerings.util.ResultListener;
import com.threerings.presents.client.BasicDirector;
import com.threerings.presents.client.Client;
import com.threerings.presents.client.ClientEvent;
import com.threerings.presents.dobj.DObject;
import com.threerings.presents.dobj.ObjectAccessError;
@@ -48,7 +47,7 @@ import com.threerings.crowd.util.CrowdContext;
* before actually issuing the request.
*/
public class LocationDirector extends BasicDirector
implements Subscriber, LocationReceiver, MoveListener
implements Subscriber, LocationReceiver
{
/**
* Used to recover from a moveTo request that was accepted but
@@ -164,9 +163,35 @@ public class LocationDirector extends BasicDirector
// make a note of our pending place id
_pendingPlaceId = placeId;
var listener :MoveListenerProxy = new MoveListenerProxy();
// documentation inherited from interface MoveListener
listener.moveSucceeded = function (config :PlaceConfig) :void
{
// handle the successful move
didMoveTo(_pendingPlaceId, config);
// and clear out the tracked pending oid
_pendingPlaceId = -1;
};
// documentation inherited from interface
listener.requestFailed = function (reason :String) :void
{
// clear out our pending request oid
var placeId :int = _pendingPlaceId;
_pendingPlaceId = -1;
Log.info("moveTo failed [pid=" + placeId +
", reason=" + reason + "].");
// let our observers know that something has gone horribly awry
notifyFailure(placeId, reason);
};
// issue a moveTo request
Log.info("Issuing moveTo(" + placeId + ").");
_lservice.moveTo(_cctx.getClient(), placeId, this);
_lservice.moveTo(_cctx.getClient(), placeId, listener);
return true;
}
@@ -290,7 +315,7 @@ public class LocationDirector extends BasicDirector
_placeId = placeId;
// check whether we should use a custom class loader
cclass :Class = config.getControllerClass();
var cclass :Class = config.getControllerClass();
try {
// start up a new place controller to manage the new place
_controller = (new cclass() as PlaceController);
@@ -383,7 +408,7 @@ public class LocationDirector extends BasicDirector
super.clientDidLogon(event);
// TODO: Work out new anonyclass construct
var sub :Subscriber = new SubscriberProxy();
var sub :SubscriberProxy = new SubscriberProxy();
sub.objectAvailable = function (object :DObject) :void {
gotBodyObject(object as BodyObject);
};
@@ -393,7 +418,8 @@ public class LocationDirector extends BasicDirector
"[cause=" + cause + "].");
};
var cloid :int = event.getClient().getClientOid();
var client :Client = event.getClient();
var cloid :int = client.getClientOid();
client.getDObjectManager().subscribeToObject(cloid, sub);
}
@@ -431,30 +457,6 @@ public class LocationDirector extends BasicDirector
// we'll want to be going there straight away
}
// documentation inherited from interface
public function moveSucceeded (config :PlaceConfig) :void
{
// handle the successful move
didMoveTo(_pendingPlaceId, config);
// and clear out the tracked pending oid
_pendingPlaceId = -1;
}
// documentation inherited from interface
public function requestFailed (reason :String) :void
{
// clear out our pending request oid
var placeId :int = _pendingPlaceId;
_pendingPlaceId = -1;
Log.info("moveTo failed [pid=" + placeId +
", reason=" + reason + "].");
// let our observers know that something has gone horribly awry
notifyFailure(placeId, reason);
}
// documentation inherited from interface
public function forcedMove (placeId :int) :void
{
@@ -470,10 +472,7 @@ public class LocationDirector extends BasicDirector
}
}
/**
* Called when we receive the place object to which we subscribed
* after a successful moveTo request.
*/
// documentation inherited from interface Subscriber
public function objectAvailable (object :DObject) :void
{
// yay, we have our new place object
@@ -494,12 +493,7 @@ public class LocationDirector extends BasicDirector
_observers.apply(_didChangeOp);
}
/**
* Called if we are unable to subscribe to the place object that was
* provided to us with our successful moveTo request. This is
* generally a bad scene and we do our best to recover by going back
* to the previously known location.
*/
// documentation inherited from interface Subscriber
public function requestFailed (oid :int, cause :ObjectAccessError) :void
{
// aiya! we were unable to fetch our new place object; something
@@ -520,17 +514,17 @@ public class LocationDirector extends BasicDirector
// does whatever's necessary
// try to return to our previous location
if (_failureHandler != null) {
_failureHandler.recoverFailedMove(placeId);
} else {
// if (_failureHandler != null) {
// _failureHandler.recoverFailedMove(placeId);
//
// } else {
// if we were previously somewhere (and that somewhere isn't
// where we just tried to go), try going back to that happy
// place
if (_previousPlaceId != -1 && _previousPlaceId != placeId) {
moveTo(_previousPlaceId);
}
}
// }
}
/**
@@ -618,7 +612,12 @@ public class LocationDirector extends BasicDirector
}
import com.threerings.presents.dobj.Subscriber;
import com.threerings.crowd.client.MoveListener;
dynamic class SubscriberProxy implements Subscriber
{
}
dynamic class MoveListenerProxy implements MoveListener
{
}
@@ -53,3 +53,4 @@ public interface LocationService extends InvocationService
*/
function leavePlace (client :Client) :void;
}
}
@@ -1,7 +1,10 @@
package com.threerings.crowd.client {
import com.threerings.presents.client.ClientEvent;
import com.threerings.presents.client.InvocationListener;
import com.threerings.crowd.data.PlaceConfig;
public interface MoveListener extends InvocationListener
{
function moveSucceeded (config :PlaceConfig) :void;
@@ -47,7 +47,7 @@ public interface PlaceConfig extends Streamable
* this place. The controller class must derive from {@link
* PlaceController}.
*/
public function getControllerClass () :Class;
function getControllerClass () :Class;
/**
* Returns the name of the class that should be used to create a
@@ -120,7 +120,7 @@ public class PlaceObject extends DObject
*/
public function addToOccupantInfo (elem :DSetEntry) :void
{
requestEntryAdd(OCCUPANT_INFO, occupantInfo, elem);
requestEntryAdd(OCCUPANT_INFO, elem);
}
/**
@@ -130,7 +130,7 @@ public class PlaceObject extends DObject
*/
public function removeFromOccupantInfo (key :Object) :void
{
requestEntryRemove(OCCUPANT_INFO, occupantInfo, key);
requestEntryRemove(OCCUPANT_INFO, key);
}
/**
@@ -140,7 +140,7 @@ public class PlaceObject extends DObject
*/
public function updateOccupantInfo (elem :DSetEntry) :void
{
requestEntryUpdate(OCCUPANT_INFO, occupantInfo, elem);
requestEntryUpdate(OCCUPANT_INFO, elem);
}
/**