Chat revamp, phase 1.

- Repackaged crowd/chat
- All messages are delivered to the client via ChatMessage messages,
  including tells.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2631 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2003-06-03 21:41:33 +00:00
parent 368cd940b6
commit 40afe3cb94
33 changed files with 218 additions and 416 deletions
@@ -1,56 +0,0 @@
//
// $Id: ChatDecoder.java,v 1.2 2002/08/20 19:38:13 mdb Exp $
package com.threerings.crowd.chat;
import com.threerings.crowd.chat.ChatReceiver;
import com.threerings.presents.client.InvocationDecoder;
/**
* Dispatches calls to a {@link ChatReceiver} instance.
*
* <p> Generated from <code>
* $Id: ChatDecoder.java,v 1.2 2002/08/20 19:38:13 mdb Exp $
* </code>
*/
public class ChatDecoder extends InvocationDecoder
{
/** The generated hash code used to identify this receiver class. */
public static final String RECEIVER_CODE = "50d26fa68e407846184dc06b78db3e1d";
/** The method id used to dispatch {@link ChatReceiver#receivedTell}
* notifications. */
public static final int RECEIVED_TELL = 1;
/**
* Creates a decoder that may be registered to dispatch invocation
* service notifications to the specified receiver.
*/
public ChatDecoder (ChatReceiver receiver)
{
this.receiver = receiver;
}
// documentation inherited
public String getReceiverCode ()
{
return RECEIVER_CODE;
}
// documentation inherited
public void dispatchNotification (int methodId, Object[] args)
{
switch (methodId) {
case RECEIVED_TELL:
((ChatReceiver)receiver).receivedTell(
(String)args[0], (String)args[1], (String)args[2]
);
return;
default:
super.dispatchNotification(methodId, args);
}
}
// Generated on 12:36:59 08/20/02.
}
@@ -1,7 +1,7 @@
// //
// $Id: ChatDirector.java,v 1.43 2003/01/21 01:08:36 mdb Exp $ // $Id: ChatDirector.java,v 1.44 2003/06/03 21:41:33 ray Exp $
package com.threerings.crowd.chat; package com.threerings.crowd.chat.client;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
@@ -11,6 +11,7 @@ import com.samskivert.util.ObserverList;
import com.threerings.presents.client.BasicDirector; import com.threerings.presents.client.BasicDirector;
import com.threerings.presents.client.Client; import com.threerings.presents.client.Client;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.dobj.DObject; import com.threerings.presents.dobj.DObject;
import com.threerings.presents.dobj.MessageEvent; import com.threerings.presents.dobj.MessageEvent;
import com.threerings.presents.dobj.MessageListener; import com.threerings.presents.dobj.MessageListener;
@@ -24,13 +25,20 @@ import com.threerings.crowd.client.LocationObserver;
import com.threerings.crowd.data.PlaceObject; import com.threerings.crowd.data.PlaceObject;
import com.threerings.crowd.util.CrowdContext; import com.threerings.crowd.util.CrowdContext;
import com.threerings.crowd.chat.data.ChatCodes;
import com.threerings.crowd.chat.data.ChatMessage;
import com.threerings.crowd.chat.data.FeedbackMessage;
import com.threerings.crowd.chat.data.SystemMessage;
import com.threerings.crowd.chat.data.TellFeedbackMessage;
import com.threerings.crowd.chat.data.UserMessage;
/** /**
* The chat director is the client side coordinator of all chat related * The chat director is the client side coordinator of all chat related
* services. It handles both place constrained chat as well as direct * services. It handles both place constrained chat as well as direct
* messaging. * messaging.
*/ */
public class ChatDirector extends BasicDirector public class ChatDirector extends BasicDirector
implements ChatCodes, LocationObserver, MessageListener, ChatReceiver implements ChatCodes, LocationObserver, MessageListener
{ {
/** /**
* An interface to receive information about the {@link #MAX_CHATTERS} * An interface to receive information about the {@link #MAX_CHATTERS}
@@ -71,10 +79,6 @@ public class ChatDirector extends BasicDirector
_msgmgr = msgmgr; _msgmgr = msgmgr;
_bundle = bundle; _bundle = bundle;
// register for chat notifications
_ctx.getClient().getInvocationDirector().registerReceiver(
new ChatDecoder(this));
// register ourselves as a location observer // register ourselves as a location observer
_ctx.getLocationDirector().addLocationObserver(this); _ctx.getLocationDirector().addLocationObserver(this);
} }
@@ -234,7 +238,9 @@ public class ChatDirector extends BasicDirector
public void displaySystemMessage ( public void displaySystemMessage (
String bundle, String message, String localtype) String bundle, String message, String localtype)
{ {
dispatchMessage(new SystemMessage(xlate(bundle, message), localtype)); SystemMessage msg = new SystemMessage();
msg.setClientInfo(xlate(bundle, message), localtype);
dispatchMessage(msg);
} }
/** /**
@@ -259,7 +265,9 @@ public class ChatDirector extends BasicDirector
public void displayFeedbackMessage (String bundle, String message, public void displayFeedbackMessage (String bundle, String message,
String localtype) String localtype)
{ {
dispatchMessage(new FeedbackMessage(xlate(bundle, message), localtype)); FeedbackMessage msg = new FeedbackMessage();
msg.setClientInfo(xlate(bundle, message), localtype);
dispatchMessage(msg);
} }
/** /**
@@ -322,7 +330,7 @@ public class ChatDirector extends BasicDirector
public void requestBroadcast (String message) public void requestBroadcast (String message)
{ {
_cservice.broadcast( _cservice.broadcast(
_ctx.getClient(), message, new ChatService.InvocationListener () { _ctx.getClient(), message, new ChatService.InvocationListener() {
public void requestFailed (String reason) { public void requestFailed (String reason) {
displayFeedbackMessage( displayFeedbackMessage(
_bundle, MessageBundle.compose( _bundle, MessageBundle.compose(
@@ -351,19 +359,18 @@ public class ChatDirector extends BasicDirector
// create a listener that will report success or failure // create a listener that will report success or failure
ChatService.TellListener listener = new ChatService.TellListener() { ChatService.TellListener listener = new ChatService.TellListener() {
public void tellSucceeded () { public void tellSucceeded () {
String msg = MessageBundle.tcompose( dispatchMessage(new TellFeedbackMessage(
"m.told_format", target, message); xlate(_bundle, MessageBundle.tcompose(
displayFeedbackMessage(_bundle, msg); "m.told_format", target, message))));
addChatter(target); addChatter(target);
} }
public void tellSucceededIdle (long idletime) { public void tellSucceededIdle (long idletime) {
String msg = MessageBundle.compose( dispatchMessage(new TellFeedbackMessage(
xlate(_bundle, MessageBundle.compose(
"m.told_idle_format", MessageBundle.taint(target), "m.told_idle_format", MessageBundle.taint(target),
MessageBundle.taint(message), MessageBundle.taint(message),
TimeUtil.getTimeOrderString(idletime, TimeUtil.MINUTE)); TimeUtil.getTimeOrderString(idletime, TimeUtil.MINUTE)))));
displayFeedbackMessage(_bundle, msg);
addChatter(target); addChatter(target);
} }
@@ -439,71 +446,31 @@ public class ChatDirector extends BasicDirector
// documentation inherited // documentation inherited
public void messageReceived (MessageEvent event) public void messageReceived (MessageEvent event)
{ {
String name = event.getName(); if (CHAT_NOTIFICATION.equals(event.getName())) {
if (name.equals(SPEAK_NOTIFICATION)) { ChatMessage msg = (ChatMessage) event.getArgs()[0];
handleSpeakMessage( String localtype = getLocalType(event.getTargetOid());
getLocalType(event.getTargetOid()), event.getArgs());
} else if (name.equals(SYSTEM_NOTIFICATION)) { // if the message came from a user, make sure we want to hear it
Object[] args = event.getArgs(); if (msg instanceof UserMessage) {
displaySystemMessage((String)args[0], (String)args[1], String speaker = ((UserMessage) msg).speaker;
getLocalType(event.getTargetOid())); if (isBlocked(speaker)) {
// ack! block that message
return;
} else if (USER_CHAT_TYPE.equals(localtype)) {
// if it was a tell, add the speaker as a chatter
addChatter(speaker);
}
}
// initialize the client-specific fields of the message
msg.setClientInfo(xlate(msg.bundle, msg.message), localtype);
// and send it off!
dispatchMessage(msg);
} }
} }
// documentation inherited from interface
public void receivedTell (String speaker, String bundle, String message)
{
// ignore messages from blocked users
if (isBlocked(speaker)) {
return;
}
// if the message need be translated, do so
if (bundle != null) {
message = xlate(bundle, message);
}
UserMessage um = new UserMessage(
message, ChatCodes.TELL_CHAT_TYPE, speaker, ChatCodes.DEFAULT_MODE);
dispatchMessage(um);
addChatter(speaker);
}
/**
* Called when a speak message is received on the place object or one
* of our auxiliary chat objects.
*
* @param type {@link ChatCodes#PLACE_CHAT_TYPE} if the message was
* received on the place object or the type associated with the
* auxiliary chat object on which the message was received.
* @param args the arguments provided with the speak notification.
*/
protected void handleSpeakMessage (String localtype, Object[] args)
{
String speaker = (String)args[0];
// bail if the speaker is blocked
if (isBlocked(speaker)) {
return;
}
String message;
byte mode;
// determine whether this speak message originated from another
// client or from a server entity
if (args.length == 3) {
message = (String)args[1];
mode = ((Byte) args[2]).byteValue();
} else {
message = xlate((String) args[1], (String) args[2]);
mode = ((Byte) args[3]).byteValue();
}
dispatchMessage(new UserMessage(message, localtype, speaker, mode));
}
/** /**
* Translates the specified message using the specified bundle. * Translates the specified message using the specified bundle.
*/ */
@@ -557,11 +524,24 @@ public class ChatDirector extends BasicDirector
return _requestId++; return _requestId++;
} }
// documentation inherited
public void clientDidLogon (Client client)
{
super.clientDidLogon(client);
// listen on the client object for tells
addAuxiliarySource(_clobj = client.getClientObject(), USER_CHAT_TYPE);
}
// documentation inherited // documentation inherited
public void clientObjectDidChange (Client client) public void clientObjectDidChange (Client client)
{ {
super.clientObjectDidChange(client); super.clientObjectDidChange(client);
// change what we're listening to for tells
removeAuxiliarySource(_clobj);
addAuxiliarySource(_clobj = client.getClientObject(), USER_CHAT_TYPE);
clearDisplays(); clearDisplays();
} }
@@ -570,6 +550,10 @@ public class ChatDirector extends BasicDirector
{ {
super.clientDidLogoff(client); super.clientDidLogoff(client);
// stop listening to it for tells
removeAuxiliarySource(_clobj);
_clobj = null;
clearDisplays(); clearDisplays();
// clear out the list of people we've chatted with // clear out the list of people we've chatted with
@@ -622,6 +606,9 @@ public class ChatDirector extends BasicDirector
protected boolean _valid; protected boolean _valid;
} }
/**
* An observer op used to dispatch ChatMessages on the client.
*/
protected static class DisplayMessageOp implements ObserverList.ObserverOp protected static class DisplayMessageOp implements ObserverList.ObserverOp
{ {
public void setMessage (ChatMessage message) public void setMessage (ChatMessage message)
@@ -653,6 +640,9 @@ public class ChatDirector extends BasicDirector
/** The place object that we currently occupy. */ /** The place object that we currently occupy. */
protected PlaceObject _place; protected PlaceObject _place;
/** The client object that we're listening to for tells. */
protected ClientObject _clobj;
/** A list of registered chat displays. */ /** A list of registered chat displays. */
protected ObserverList _displays = protected ObserverList _displays =
new ObserverList(ObserverList.FAST_UNSAFE_NOTIFY); new ObserverList(ObserverList.FAST_UNSAFE_NOTIFY);
@@ -1,7 +1,9 @@
// //
// $Id: ChatDisplay.java,v 1.16 2002/11/08 07:28:23 ray Exp $ // $Id: ChatDisplay.java,v 1.17 2003/06/03 21:41:33 ray Exp $
package com.threerings.crowd.chat; package com.threerings.crowd.chat.client;
import com.threerings.crowd.chat.data.ChatMessage;
/** /**
* A chat display provides a means by which chat messages can be * A chat display provides a means by which chat messages can be
@@ -1,30 +0,0 @@
//
// $Id: ChatReceiver.java,v 1.3 2002/08/14 19:07:49 mdb Exp $
package com.threerings.crowd.chat;
import com.threerings.presents.client.InvocationReceiver;
/**
* Defines, for the chat services, a set of notifications delivered
* asynchronously by the server to the client.
*/
public interface ChatReceiver extends InvocationReceiver
{
/**
* Called when a tell message is received from another player on the
* server.
*
* @param speaker the username of the user from which this message
* originated.
* @param bundle if non-null, a bundle that should be used to
* translate the text of the tell message. This is generally only used
* when some server entity originates the tell message rather than
* another user. The server entity might then wish for its tell
* message to be translated into a language appropriate for the
* receiver. Such luxuries are not available for human to human
* conversation, alas.
* @param message the text of the tell message.
*/
public void receivedTell (String speaker, String bundle, String message);
}
@@ -1,7 +1,7 @@
// //
// $Id: ChatService.java,v 1.10 2002/10/31 23:27:16 mdb Exp $ // $Id: ChatService.java,v 1.11 2003/06/03 21:41:33 ray Exp $
package com.threerings.crowd.chat; package com.threerings.crowd.chat.client;
import com.threerings.presents.client.Client; import com.threerings.presents.client.Client;
import com.threerings.presents.client.InvocationService; import com.threerings.presents.client.InvocationService;
@@ -1,7 +1,7 @@
// //
// $Id: ChatValidator.java,v 1.1 2002/06/19 23:12:48 ray Exp $ // $Id: ChatValidator.java,v 1.2 2003/06/03 21:41:33 ray Exp $
package com.threerings.crowd.chat; package com.threerings.crowd.chat.client;
/** /**
* A chat validator validates chat messages before they are sent to the * A chat validator validates chat messages before they are sent to the
@@ -1,7 +1,7 @@
// //
// $Id: MuteDirector.java,v 1.7 2003/04/08 02:49:43 ray Exp $ // $Id: MuteDirector.java,v 1.8 2003/06/03 21:41:33 ray Exp $
package com.threerings.crowd.chat; package com.threerings.crowd.chat.client;
import java.util.HashSet; import java.util.HashSet;
@@ -1,7 +1,7 @@
// //
// $Id: SpeakService.java,v 1.1 2002/08/14 19:07:49 mdb Exp $ // $Id: SpeakService.java,v 1.2 2003/06/03 21:41:33 ray Exp $
package com.threerings.crowd.chat; package com.threerings.crowd.chat.client;
import com.threerings.presents.client.Client; import com.threerings.presents.client.Client;
import com.threerings.presents.client.InvocationService; import com.threerings.presents.client.InvocationService;
@@ -1,7 +1,7 @@
// //
// $Id: ChatCodes.java,v 1.15 2003/03/30 02:53:05 mdb Exp $ // $Id: ChatCodes.java,v 1.16 2003/06/03 21:41:33 ray Exp $
package com.threerings.crowd.chat; package com.threerings.crowd.chat.data;
import com.threerings.presents.data.InvocationCodes; import com.threerings.presents.data.InvocationCodes;
@@ -10,6 +10,9 @@ import com.threerings.presents.data.InvocationCodes;
*/ */
public interface ChatCodes extends InvocationCodes public interface ChatCodes extends InvocationCodes
{ {
/** The message identifier for a chat notification message. */
public static final String CHAT_NOTIFICATION = "chat";
/** The chat localtype code for chat messages delivered on the place /** The chat localtype code for chat messages delivered on the place
* object currently occupied by the client. This is the only type of * object currently occupied by the client. This is the only type of
* chat message that will be delivered unless the chat director is * chat message that will be delivered unless the chat director is
@@ -17,14 +20,8 @@ public interface ChatCodes extends InvocationCodes
* ChatDirector#addAuxiliarySource}. */ * ChatDirector#addAuxiliarySource}. */
public static final String PLACE_CHAT_TYPE = "placeChat"; public static final String PLACE_CHAT_TYPE = "placeChat";
/** The message identifier for a speak notification message. */ /** The chat localtype for messages received on the user object. */
public static final String SPEAK_NOTIFICATION = "spknot"; public static final String USER_CHAT_TYPE = "userChat";
/** The message identifier for a system notification message. */
public static final String SYSTEM_NOTIFICATION = "sysnot";
/** The chat localtype for tells. */
public static final String TELL_CHAT_TYPE = "tellChat";
/** The default mode used by {@link SpeakService#speak} requests. */ /** The default mode used by {@link SpeakService#speak} requests. */
public static final byte DEFAULT_MODE = 0; public static final byte DEFAULT_MODE = 0;
@@ -1,10 +1,10 @@
// //
// $Id: ChatMarshaller.java,v 1.4 2002/10/31 23:27:16 mdb Exp $ // $Id: ChatMarshaller.java,v 1.5 2003/06/03 21:41:33 ray Exp $
package com.threerings.crowd.chat; package com.threerings.crowd.chat.data;
import com.threerings.crowd.chat.ChatService; import com.threerings.crowd.chat.client.ChatService;
import com.threerings.crowd.chat.ChatService.TellListener; import com.threerings.crowd.chat.client.ChatService.TellListener;
import com.threerings.presents.client.Client; import com.threerings.presents.client.Client;
import com.threerings.presents.client.InvocationService.InvocationListener; import com.threerings.presents.client.InvocationService.InvocationListener;
import com.threerings.presents.data.InvocationMarshaller; import com.threerings.presents.data.InvocationMarshaller;
@@ -94,5 +94,4 @@ public class ChatMarshaller extends InvocationMarshaller
}); });
} }
// Generated on 13:40:31 10/31/02.
} }
@@ -1,32 +1,56 @@
// //
// $Id: ChatMessage.java,v 1.3 2003/03/30 02:52:53 mdb Exp $ // $Id: ChatMessage.java,v 1.4 2003/06/03 21:41:33 ray Exp $
package com.threerings.crowd.chat; package com.threerings.crowd.chat.data;
import com.samskivert.util.StringUtil; import com.samskivert.util.StringUtil;
import com.threerings.io.Streamable;
/** /**
* The abstract base class of all the client-side ChatMessage objects. * The abstract base class of all the client-side ChatMessage objects.
*/ */
public abstract class ChatMessage public abstract class ChatMessage
implements Streamable
{ {
/** The actual text of the message. */ /** The actual text of the message. */
public String message; public String message;
/** The localtype of this chat, set to the type registered with an /** The bundle to use when translating this message. */
* auxiliary source in the ChatDirector. */ public String bundle;
public String localtype;
/** The time that this message was created on the client. */ /** The client side 'localtype' of this chat, set to the type
public long timestamp; * registered with an auxiliary source in the ChatDirector. */
public transient String localtype;
/** The client time that this message was created. */
public transient long timestamp;
/**
* For all your unserialization needs.
*/
public ChatMessage ()
{
}
/** /**
* Construct a ChatMessage. * Construct a ChatMessage.
*/ */
public ChatMessage (String message, String localtype) public ChatMessage (String message, String bundle)
{ {
this.message = message; this.message = message;
this.bundle = bundle;
}
/**
* Once this message reaches the client, the information contained within
* is changed around a bit.
*/
public void setClientInfo (String msg, String localtype)
{
message = msg;
this.localtype = localtype; this.localtype = localtype;
bundle = null;
timestamp = System.currentTimeMillis(); timestamp = System.currentTimeMillis();
} }
@@ -1,7 +1,7 @@
// //
// $Id: FeedbackMessage.java,v 1.1 2002/07/26 20:35:01 ray Exp $ // $Id: FeedbackMessage.java,v 1.2 2003/06/03 21:41:33 ray Exp $
package com.threerings.crowd.chat; package com.threerings.crowd.chat.data;
/** /**
* A ChatMessage to indicate to the user that an action they took * A ChatMessage to indicate to the user that an action they took
@@ -9,6 +9,10 @@ package com.threerings.crowd.chat;
*/ */
public class FeedbackMessage extends ChatMessage public class FeedbackMessage extends ChatMessage
{ {
public FeedbackMessage ()
{
}
/** /**
* Construct a FeedbackMessage. * Construct a FeedbackMessage.
*/ */
@@ -1,9 +1,9 @@
// //
// $Id: SpeakMarshaller.java,v 1.2 2002/08/20 19:38:13 mdb Exp $ // $Id: SpeakMarshaller.java,v 1.3 2003/06/03 21:41:33 ray Exp $
package com.threerings.crowd.chat; package com.threerings.crowd.chat.data;
import com.threerings.crowd.chat.SpeakService; import com.threerings.crowd.chat.client.SpeakService;
import com.threerings.presents.client.Client; import com.threerings.presents.client.Client;
import com.threerings.presents.data.InvocationMarshaller; import com.threerings.presents.data.InvocationMarshaller;
import com.threerings.presents.dobj.InvocationResponseEvent; import com.threerings.presents.dobj.InvocationResponseEvent;
@@ -14,10 +14,6 @@ import com.threerings.presents.dobj.InvocationResponseEvent;
* on the server. Also provides an implementation of the response listener * on the server. Also provides an implementation of the response listener
* interfaces that marshall the response arguments and deliver them back * interfaces that marshall the response arguments and deliver them back
* to the requesting client. * to the requesting client.
*
* <p> Generated from <code>
* $Id: SpeakMarshaller.java,v 1.2 2002/08/20 19:38:13 mdb Exp $
* </code>
*/ */
public class SpeakMarshaller extends InvocationMarshaller public class SpeakMarshaller extends InvocationMarshaller
implements SpeakService implements SpeakService
@@ -33,5 +29,4 @@ public class SpeakMarshaller extends InvocationMarshaller
}); });
} }
// Class file generated on 12:33:01 08/20/02.
} }
@@ -1,7 +1,7 @@
// //
// $Id: SystemMessage.java,v 1.1 2002/07/26 20:35:01 ray Exp $ // $Id: SystemMessage.java,v 1.2 2003/06/03 21:41:33 ray Exp $
package com.threerings.crowd.chat; package com.threerings.crowd.chat.data;
/** /**
* A ChatMessage that represents a message that came from the server * A ChatMessage that represents a message that came from the server
@@ -9,11 +9,15 @@ package com.threerings.crowd.chat;
*/ */
public class SystemMessage extends ChatMessage public class SystemMessage extends ChatMessage
{ {
public SystemMessage ()
{
}
/** /**
* Construct a SystemMessage. * Construct a SystemMessage.
*/ */
public SystemMessage (String message, String localtype) public SystemMessage (String message, String bundle)
{ {
super(message, localtype); super(message, bundle);
} }
} }
@@ -1,7 +1,7 @@
// //
// $Id: UserMessage.java,v 1.1 2002/07/26 20:35:01 ray Exp $ // $Id: UserMessage.java,v 1.2 2003/06/03 21:41:33 ray Exp $
package com.threerings.crowd.chat; package com.threerings.crowd.chat.data;
/** /**
* A ChatMessage representing a message that came from another user. * A ChatMessage representing a message that came from another user.
@@ -14,13 +14,20 @@ public class UserMessage extends ChatMessage
/** The mode of the message. @see ChatCodes.DEFAULT_MODE */ /** The mode of the message. @see ChatCodes.DEFAULT_MODE */
public byte mode; public byte mode;
/**
* For unserialization.
*/
public UserMessage ()
{
}
/** /**
* Construct a user message. * Construct a user message.
*/ */
public UserMessage (String message, String localtype, public UserMessage (String message, String bundle,
String speaker, byte mode) String speaker, byte mode)
{ {
super(message, localtype); super(message, bundle);
this.speaker = speaker; this.speaker = speaker;
this.mode = mode; this.mode = mode;
} }
@@ -1,11 +1,11 @@
// //
// $Id: ChatDispatcher.java,v 1.4 2002/10/31 23:27:16 mdb Exp $ // $Id: ChatDispatcher.java,v 1.5 2003/06/03 21:41:33 ray Exp $
package com.threerings.crowd.chat; package com.threerings.crowd.chat.server;
import com.threerings.crowd.chat.ChatMarshaller; import com.threerings.crowd.chat.client.ChatService;
import com.threerings.crowd.chat.ChatService; import com.threerings.crowd.chat.client.ChatService.TellListener;
import com.threerings.crowd.chat.ChatService.TellListener; import com.threerings.crowd.chat.data.ChatMarshaller;
import com.threerings.presents.client.Client; import com.threerings.presents.client.Client;
import com.threerings.presents.client.InvocationService.InvocationListener; import com.threerings.presents.client.InvocationService.InvocationListener;
import com.threerings.presents.data.ClientObject; import com.threerings.presents.data.ClientObject;
@@ -57,6 +57,4 @@ public class ChatDispatcher extends InvocationDispatcher
super.dispatchRequest(source, methodId, args); super.dispatchRequest(source, methodId, args);
} }
} }
// Generated on 13:40:31 10/31/02.
} }
@@ -1,7 +1,7 @@
// //
// $Id: ChatProvider.java,v 1.18 2002/11/01 01:01:27 mdb Exp $ // $Id: ChatProvider.java,v 1.19 2003/06/03 21:41:33 ray Exp $
package com.threerings.crowd.chat; package com.threerings.crowd.chat.server;
import java.util.Iterator; import java.util.Iterator;
@@ -23,7 +23,9 @@ import com.threerings.crowd.data.OccupantInfo;
import com.threerings.crowd.data.PlaceObject; import com.threerings.crowd.data.PlaceObject;
import com.threerings.crowd.server.CrowdServer; import com.threerings.crowd.server.CrowdServer;
import com.threerings.crowd.chat.ChatService.TellListener; import com.threerings.crowd.chat.client.ChatService.TellListener;
import com.threerings.crowd.chat.data.ChatCodes;
import com.threerings.crowd.chat.data.UserMessage;
/** /**
* The chat provider handles the server side of the chat-related * The chat provider handles the server side of the chat-related
@@ -123,7 +125,8 @@ public class ChatProvider
public static void sendTellMessage ( public static void sendTellMessage (
BodyObject target, String speaker, String bundle, String message) BodyObject target, String speaker, String bundle, String message)
{ {
ChatSender.sendTell(target, speaker, bundle, message); SpeakProvider.sendMessage(target,
new UserMessage(message, bundle, speaker, DEFAULT_MODE));
} }
/** The distributed object manager used by the chat services. */ /** The distributed object manager used by the chat services. */
@@ -1,34 +0,0 @@
//
// $Id: ChatSender.java,v 1.2 2002/08/20 19:38:13 mdb Exp $
package com.threerings.crowd.chat;
import com.threerings.crowd.chat.ChatDecoder;
import com.threerings.crowd.chat.ChatReceiver;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.server.InvocationSender;
/**
* Used to issue notifications to a {@link ChatReceiver} instance on a
* client.
*
* <p> Generated from <code>
* $Id: ChatSender.java,v 1.2 2002/08/20 19:38:13 mdb Exp $
* </code>
*/
public class ChatSender extends InvocationSender
{
/**
* Issues a notification that will result in a call to {@link
* ChatReceiver#receivedTell} on a client.
*/
public static void sendTell (
ClientObject target, String arg1, String arg2, String arg3)
{
sendNotification(
target, ChatDecoder.RECEIVER_CODE, ChatDecoder.RECEIVED_TELL,
new Object[] { arg1, arg2, arg3 });
}
// Generated on 12:36:59 08/20/02.
}
@@ -1,10 +1,10 @@
// //
// $Id: SpeakDispatcher.java,v 1.2 2002/08/20 19:38:13 mdb Exp $ // $Id: SpeakDispatcher.java,v 1.3 2003/06/03 21:41:33 ray Exp $
package com.threerings.crowd.chat; package com.threerings.crowd.chat.server;
import com.threerings.crowd.chat.SpeakMarshaller; import com.threerings.crowd.chat.client.SpeakService;
import com.threerings.crowd.chat.SpeakService; import com.threerings.crowd.chat.data.SpeakMarshaller;
import com.threerings.presents.client.Client; import com.threerings.presents.client.Client;
import com.threerings.presents.data.ClientObject; import com.threerings.presents.data.ClientObject;
import com.threerings.presents.data.InvocationMarshaller; import com.threerings.presents.data.InvocationMarshaller;
@@ -13,10 +13,6 @@ import com.threerings.presents.server.InvocationException;
/** /**
* Dispatches requests to the {@link SpeakProvider}. * Dispatches requests to the {@link SpeakProvider}.
*
* <p> Generated from <code>
* $Id: SpeakDispatcher.java,v 1.2 2002/08/20 19:38:13 mdb Exp $
* </code>
*/ */
public class SpeakDispatcher extends InvocationDispatcher public class SpeakDispatcher extends InvocationDispatcher
{ {
@@ -1,7 +1,7 @@
// //
// $Id: SpeakProvider.java,v 1.4 2003/03/30 02:52:41 mdb Exp $ // $Id: SpeakProvider.java,v 1.5 2003/06/03 21:41:33 ray Exp $
package com.threerings.crowd.chat; package com.threerings.crowd.chat.server;
import com.samskivert.util.ObserverList; import com.samskivert.util.ObserverList;
@@ -13,6 +13,11 @@ import com.threerings.presents.server.InvocationProvider;
import com.threerings.crowd.Log; import com.threerings.crowd.Log;
import com.threerings.crowd.data.BodyObject; import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.chat.data.ChatCodes;
import com.threerings.crowd.chat.data.ChatMessage;
import com.threerings.crowd.chat.data.SystemMessage;
import com.threerings.crowd.chat.data.UserMessage;
/** /**
* Provides the back-end of the chat speaking facilities. A server entity * Provides the back-end of the chat speaking facilities. A server entity
* can make "speech" available among the subscribers of a particular * can make "speech" available among the subscribers of a particular
@@ -37,28 +42,6 @@ public class SpeakProvider
public boolean isValidSpeaker (DObject speakObj, ClientObject speaker); public boolean isValidSpeaker (DObject speakObj, ClientObject speaker);
} }
/**
* An interface to be implemented by entities that would like to be
* notified of all speak messages.
*/
public static interface SpeakObserver
{
/**
* Called with the relevant details for every speak message sent
* by the speak provider.
*/
public void handleSpeakMessage (DObject speakObj, String speaker,
String bundle, String message,
byte mode);
/**
* Called with the relevant details for every system speak message
* sent by the speak provider.
*/
public void handleSystemSpeakMessage (
DObject speakObj, String bundle, String message);
}
/** /**
* Creates a speak provider that will provide speech on the supplied * Creates a speak provider that will provide speech on the supplied
* distributed object. * distributed object.
@@ -80,7 +63,11 @@ public class SpeakProvider
public void speak (ClientObject caller, String message, byte mode) public void speak (ClientObject caller, String message, byte mode)
{ {
// ensure that the speaker is valid // ensure that the speaker is valid
if (!_validator.isValidSpeaker(_speakObj, caller)) { // TODO: broadcast should be handled more like a system message
// rather than as a mode for a user message so that we don't
// have to do this validation here. Or not.
if ((mode == BROADCAST_MODE) ||
!_validator.isValidSpeaker(_speakObj, caller)) {
Log.warning("Refusing invalid speak request " + Log.warning("Refusing invalid speak request " +
"[caller=" + caller.who() + "[caller=" + caller.who() +
", speakObj=" + _speakObj.which() + ", speakObj=" + _speakObj.which() +
@@ -93,24 +80,6 @@ public class SpeakProvider
} }
} }
/**
* Registers the supplied speak observer to be notified of all speak
* messages.
*/
public static void addSpeakObserver (SpeakObserver obs)
{
_observers.add(obs);
}
/**
* Removes the supplied speak observer from the list of observers to
* be notified of all speak messages.
*/
public static void removeSpeakObserver (SpeakObserver obs)
{
_observers.remove(obs);
}
/** /**
* Sends a speak notification to the specified place object * Sends a speak notification to the specified place object
* originating with the specified speaker (the speaker optionally * originating with the specified speaker (the speaker optionally
@@ -152,17 +121,7 @@ public class SpeakProvider
public static void sendSpeak (DObject speakObj, String speaker, public static void sendSpeak (DObject speakObj, String speaker,
String bundle, String message, byte mode) String bundle, String message, byte mode)
{ {
// pass the message along to all observers sendMessage(speakObj, new UserMessage(message, bundle, speaker, mode));
notifyObservers(speakObj, speaker, bundle, message, mode);
// post the message to the relevant object
Object[] outargs = null;
if (bundle == null) {
outargs = new Object[] { speaker, message, new Byte(mode) };
} else {
outargs = new Object[] { speaker, bundle, message, new Byte(mode) };
}
speakObj.postMessage(SPEAK_NOTIFICATION, outargs);
} }
/** /**
@@ -180,60 +139,16 @@ public class SpeakProvider
public static void sendSystemSpeak ( public static void sendSystemSpeak (
DObject speakObj, String bundle, String message) DObject speakObj, String bundle, String message)
{ {
// pass the message along to all observers sendMessage(speakObj, new SystemMessage(message, bundle));
notifyObservers(speakObj, null, bundle, message,
ChatCodes.DEFAULT_MODE);
// post the message to the relevant object
speakObj.postMessage(
SYSTEM_NOTIFICATION, new Object[] { bundle, message });
} }
/** /**
* Notifies all registered speak observers of the supplied speak * Send the specified message on the specified object.
* message.
*/ */
protected static void notifyObservers (DObject speakObj, String speaker, public static void sendMessage (DObject speakObj, ChatMessage msg)
String bundle, String message,
byte mode)
{ {
_spokenOp.setMessage(speakObj, speaker, bundle, message, mode); // post the message to the relevant object
_observers.apply(_spokenOp); speakObj.postMessage(CHAT_NOTIFICATION, new Object[] { msg });
}
protected static class SpokenOp implements ObserverList.ObserverOp
{
/**
* Sets the message information to be passed along to all {@link
* SpeakObserver}s.
*/
public void setMessage (DObject speakObj, String speaker, String bundle,
String message, byte mode)
{
_speakObj = speakObj;
_speaker = speaker;
_bundle = bundle;
_message = message;
_mode = mode;
}
// documentation inherited
public boolean apply (Object observer)
{
if (_speaker == null) {
((SpeakObserver)observer).handleSystemSpeakMessage(
_speakObj, _bundle, _message);
} else {
((SpeakObserver)observer).handleSpeakMessage(
_speakObj, _speaker, _bundle, _message, _mode);
}
return true;
}
protected DObject _speakObj;
protected String _speaker, _bundle, _message;
protected byte _mode;
} }
/** Our speech object. */ /** Our speech object. */
@@ -241,11 +156,4 @@ public class SpeakProvider
/** The entity that will validate our speakers. */ /** The entity that will validate our speakers. */
protected SpeakerValidator _validator; protected SpeakerValidator _validator;
/** The observers to be notified of all speak messages. */
protected static ObserverList _observers =
new ObserverList(ObserverList.FAST_UNSAFE_NOTIFY);
/** The operation used to notify observers of speak messages. */
protected static SpokenOp _spokenOp = new SpokenOp();
} }
@@ -1,5 +1,5 @@
// //
// $Id: BodyMarshaller.java,v 1.1 2002/11/01 00:39:18 shaper Exp $ // $Id: BodyMarshaller.java,v 1.2 2003/06/03 21:41:33 ray Exp $
package com.threerings.crowd.data; package com.threerings.crowd.data;
@@ -29,5 +29,4 @@ public class BodyMarshaller extends InvocationMarshaller
}); });
} }
// Generated on 15:58:33 10/31/02.
} }
@@ -1,5 +1,5 @@
// //
// $Id: PlaceObject.java,v 1.11 2003/04/30 22:45:57 mdb Exp $ // $Id: PlaceObject.java,v 1.12 2003/06/03 21:41:33 ray Exp $
package com.threerings.crowd.data; package com.threerings.crowd.data;
@@ -9,7 +9,7 @@ import com.threerings.presents.dobj.DObject;
import com.threerings.presents.dobj.DSet; import com.threerings.presents.dobj.DSet;
import com.threerings.presents.dobj.OidList; import com.threerings.presents.dobj.OidList;
import com.threerings.crowd.chat.SpeakMarshaller; import com.threerings.crowd.chat.data.SpeakMarshaller;
public class PlaceObject extends DObject public class PlaceObject extends DObject
{ {
@@ -1,5 +1,5 @@
// //
// $Id: BodyDispatcher.java,v 1.1 2002/11/01 00:39:18 shaper Exp $ // $Id: BodyDispatcher.java,v 1.2 2003/06/03 21:41:33 ray Exp $
package com.threerings.crowd.server; package com.threerings.crowd.server;
@@ -48,6 +48,4 @@ public class BodyDispatcher extends InvocationDispatcher
super.dispatchRequest(source, methodId, args); super.dispatchRequest(source, methodId, args);
} }
} }
// Generated on 15:58:33 10/31/02.
} }
@@ -1,5 +1,5 @@
// //
// $Id: CrowdServer.java,v 1.17 2002/11/01 21:33:49 shaper Exp $ // $Id: CrowdServer.java,v 1.18 2003/06/03 21:41:33 ray Exp $
package com.threerings.crowd.server; package com.threerings.crowd.server;
@@ -8,7 +8,7 @@ import java.util.Iterator;
import com.threerings.presents.server.PresentsServer; import com.threerings.presents.server.PresentsServer;
import com.threerings.crowd.Log; import com.threerings.crowd.Log;
import com.threerings.crowd.chat.ChatProvider; import com.threerings.crowd.chat.server.ChatProvider;
import com.threerings.crowd.data.BodyObject; import com.threerings.crowd.data.BodyObject;
/** /**
@@ -1,5 +1,5 @@
// //
// $Id: PlaceManager.java,v 1.44 2003/03/25 01:12:29 mdb Exp $ // $Id: PlaceManager.java,v 1.45 2003/06/03 21:41:33 ray Exp $
package com.threerings.crowd.server; package com.threerings.crowd.server;
@@ -34,9 +34,9 @@ import com.threerings.crowd.data.OccupantInfo;
import com.threerings.crowd.data.PlaceConfig; import com.threerings.crowd.data.PlaceConfig;
import com.threerings.crowd.data.PlaceObject; import com.threerings.crowd.data.PlaceObject;
import com.threerings.crowd.chat.SpeakDispatcher; import com.threerings.crowd.chat.data.SpeakMarshaller;
import com.threerings.crowd.chat.SpeakMarshaller; import com.threerings.crowd.chat.server.SpeakDispatcher;
import com.threerings.crowd.chat.SpeakProvider; import com.threerings.crowd.chat.server.SpeakProvider;
/** /**
* The place manager is the server-side entity that handles all * The place manager is the server-side entity that handles all
@@ -1,5 +1,5 @@
// //
// $Id: ChatPanel.java,v 1.22 2002/11/08 07:28:23 ray Exp $ // $Id: ChatPanel.java,v 1.23 2003/06/03 21:41:33 ray Exp $
package com.threerings.micasa.client; package com.threerings.micasa.client;
@@ -34,13 +34,14 @@ import com.samskivert.swing.event.AncestorAdapter;
import com.threerings.util.MessageBundle; import com.threerings.util.MessageBundle;
import com.threerings.crowd.chat.ChatCodes; import com.threerings.crowd.chat.client.ChatDirector;
import com.threerings.crowd.chat.ChatDirector; import com.threerings.crowd.chat.client.ChatDisplay;
import com.threerings.crowd.chat.ChatDisplay; import com.threerings.crowd.chat.data.ChatCodes;
import com.threerings.crowd.chat.ChatMessage; import com.threerings.crowd.chat.data.ChatMessage;
import com.threerings.crowd.chat.FeedbackMessage; import com.threerings.crowd.chat.data.FeedbackMessage;
import com.threerings.crowd.chat.SystemMessage; import com.threerings.crowd.chat.data.SystemMessage;
import com.threerings.crowd.chat.UserMessage; import com.threerings.crowd.chat.data.UserMessage;
import com.threerings.crowd.client.OccupantObserver; import com.threerings.crowd.client.OccupantObserver;
import com.threerings.crowd.client.PlaceView; import com.threerings.crowd.client.PlaceView;
import com.threerings.crowd.data.OccupantInfo; import com.threerings.crowd.data.OccupantInfo;
@@ -231,7 +232,7 @@ public class ChatPanel
{ {
if (message instanceof UserMessage) { if (message instanceof UserMessage) {
UserMessage msg = (UserMessage) message; UserMessage msg = (UserMessage) message;
if (msg.localtype == ChatCodes.TELL_CHAT_TYPE) { if (msg.localtype == ChatCodes.USER_CHAT_TYPE) {
append("[" + msg.speaker + " whispers] ", _nameStyle); append("[" + msg.speaker + " whispers] ", _nameStyle);
append(msg.message + "\n", _msgStyle); append(msg.message + "\n", _msgStyle);
} else { } else {
@@ -1,12 +1,12 @@
// //
// $Id: LobbyManager.java,v 1.5 2002/08/14 19:07:49 mdb Exp $ // $Id: LobbyManager.java,v 1.6 2003/06/03 21:41:33 ray Exp $
package com.threerings.micasa.lobby; package com.threerings.micasa.lobby;
import java.util.Properties; import java.util.Properties;
import com.samskivert.util.StringUtil; import com.samskivert.util.StringUtil;
import com.threerings.crowd.chat.ChatCodes; import com.threerings.crowd.chat.data.ChatCodes;
import com.threerings.crowd.server.PlaceManager; import com.threerings.crowd.server.PlaceManager;
import com.threerings.micasa.Log; import com.threerings.micasa.Log;
@@ -1,5 +1,5 @@
// //
// $Id: GameManager.java,v 1.63 2003/05/26 21:27:18 mdb Exp $ // $Id: GameManager.java,v 1.64 2003/06/03 21:41:33 ray Exp $
package com.threerings.parlor.game; package com.threerings.parlor.game;
@@ -16,7 +16,7 @@ import com.threerings.presents.dobj.AttributeChangedEvent;
import com.threerings.presents.dobj.MessageEvent; import com.threerings.presents.dobj.MessageEvent;
import com.threerings.presents.server.util.SafeInterval; import com.threerings.presents.server.util.SafeInterval;
import com.threerings.crowd.chat.SpeakProvider; import com.threerings.crowd.chat.server.SpeakProvider;
import com.threerings.crowd.data.BodyObject; import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.PlaceObject; import com.threerings.crowd.data.PlaceObject;
@@ -1,5 +1,5 @@
// //
// $Id: SceneMarshaller.java,v 1.3 2003/02/12 07:23:31 mdb Exp $ // $Id: SceneMarshaller.java,v 1.4 2003/06/03 21:41:33 ray Exp $
package com.threerings.whirled.data; package com.threerings.whirled.data;
@@ -100,5 +100,4 @@ public class SceneMarshaller extends InvocationMarshaller
}); });
} }
// Generated on 14:44:07 02/08/03.
} }
@@ -1,5 +1,5 @@
// //
// $Id: SceneDispatcher.java,v 1.3 2003/02/12 07:23:31 mdb Exp $ // $Id: SceneDispatcher.java,v 1.4 2003/06/03 21:41:33 ray Exp $
package com.threerings.whirled.server; package com.threerings.whirled.server;
@@ -52,6 +52,4 @@ public class SceneDispatcher extends InvocationDispatcher
super.dispatchRequest(source, methodId, args); super.dispatchRequest(source, methodId, args);
} }
} }
// Generated on 14:44:07 02/08/03.
} }
@@ -1,5 +1,5 @@
// //
// $Id: SpotSceneDirector.java,v 1.29 2003/05/06 00:21:59 mdb Exp $ // $Id: SpotSceneDirector.java,v 1.30 2003/06/03 21:41:33 ray Exp $
package com.threerings.whirled.spot.client; package com.threerings.whirled.spot.client;
@@ -18,8 +18,8 @@ import com.threerings.presents.dobj.DObjectManager;
import com.threerings.presents.dobj.ObjectAccessException; import com.threerings.presents.dobj.ObjectAccessException;
import com.threerings.presents.dobj.Subscriber; import com.threerings.presents.dobj.Subscriber;
import com.threerings.crowd.chat.ChatCodes; import com.threerings.crowd.chat.client.ChatDirector;
import com.threerings.crowd.chat.ChatDirector; import com.threerings.crowd.chat.data.ChatCodes;
import com.threerings.crowd.client.LocationAdapter; import com.threerings.crowd.client.LocationAdapter;
import com.threerings.crowd.client.LocationDirector; import com.threerings.crowd.client.LocationDirector;
import com.threerings.crowd.data.PlaceObject; import com.threerings.crowd.data.PlaceObject;
@@ -1,9 +1,9 @@
// //
// $Id: SpotCodes.java,v 1.6 2003/03/27 16:45:30 mdb Exp $ // $Id: SpotCodes.java,v 1.7 2003/06/03 21:41:33 ray Exp $
package com.threerings.whirled.spot.data; package com.threerings.whirled.spot.data;
import com.threerings.crowd.chat.ChatCodes; import com.threerings.crowd.chat.data.ChatCodes;
import com.threerings.whirled.data.SceneCodes; import com.threerings.whirled.data.SceneCodes;
import com.threerings.whirled.spot.client.SpotSceneDirector; import com.threerings.whirled.spot.client.SpotSceneDirector;
@@ -1,5 +1,5 @@
// //
// $Id: SpotSceneManager.java,v 1.40 2003/04/17 19:17:07 mdb Exp $ // $Id: SpotSceneManager.java,v 1.41 2003/06/03 21:41:33 ray Exp $
package com.threerings.whirled.spot.server; package com.threerings.whirled.spot.server;
@@ -16,7 +16,7 @@ import com.threerings.presents.dobj.Subscriber;
import com.threerings.presents.dobj.ObjectAccessException; import com.threerings.presents.dobj.ObjectAccessException;
import com.threerings.presents.server.InvocationException; import com.threerings.presents.server.InvocationException;
import com.threerings.crowd.chat.SpeakProvider; import com.threerings.crowd.chat.server.SpeakProvider;
import com.threerings.crowd.data.BodyObject; import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.OccupantInfo; import com.threerings.crowd.data.OccupantInfo;
import com.threerings.crowd.server.CrowdServer; import com.threerings.crowd.server.CrowdServer;