Added support for think and emote.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1599 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2002-07-22 22:26:26 +00:00
parent af8b7bf237
commit 5c5038690b
9 changed files with 82 additions and 25 deletions
@@ -1,5 +1,5 @@
//
// $Id: ChatDirector.java,v 1.25 2002/07/17 20:53:31 shaper Exp $
// $Id: ChatDirector.java,v 1.26 2002/07/22 22:26:26 ray Exp $
package com.threerings.crowd.chat;
@@ -351,21 +351,24 @@ public class ChatDirector
}
String bundle = null;
String message = null;
String message, mode;
// determine whether this speak message originated from another
// client or from a server entity
if (args.length == 2) {
if (args.length == 3) {
message = (String)args[1];
mode = (String) args[2];
} else {
bundle = (String)args[1];
message = (String)args[2];
mode = (String) args[3];
}
// pass this on to our chat displays
for (int i = 0; i < _displays.size(); i++) {
ChatDisplay display = (ChatDisplay)_displays.get(i);
display.displaySpeakMessage(type, speaker, bundle, message);
display.displaySpeakMessage(type, speaker, bundle, message, mode);
}
}
@@ -1,5 +1,5 @@
//
// $Id: ChatDisplay.java,v 1.10 2002/07/17 20:53:31 shaper Exp $
// $Id: ChatDisplay.java,v 1.11 2002/07/22 22:26:26 ray Exp $
package com.threerings.crowd.chat;
@@ -27,9 +27,13 @@ public interface ChatDisplay
* contain a bundle identifier that should be used to translate the
* message text.
* @param message the text of the message.
* @param mode the mode of the speak (@see ChatCodes.DEFAULT_MODE
* @see ChatCodes.THINK_MODE,
* @see ChatCodes.EMOTE_MODE ).
*/
public void displaySpeakMessage (
String type, String speaker, String bundle, String message);
String type, String speaker, String bundle, String message,
String mode);
/**
* Called to display a tell message. A tell message is one that is
@@ -1,5 +1,5 @@
//
// $Id: ChatCodes.java,v 1.7 2002/04/15 16:28:01 shaper Exp $
// $Id: ChatCodes.java,v 1.8 2002/07/22 22:26:26 ray Exp $
package com.threerings.crowd.chat;
@@ -45,6 +45,17 @@ public interface ChatCodes extends InvocationCodes
/** The message identifier for a tell notification. */
public static final String TELL_NOTIFICATION = "Tell";
/** The default mode used by speak requests. */
public static final String DEFAULT_MODE = "default";
/** The think mode to indicate that the user is thinking
* what they're saying, or is it that they're saying what they're
* thinking? */
public static final String THINK_MODE = "think";
/** The mode to indicate that a speak is actually an emote. */
public static final String EMOTE_MODE = "emote";
/** An error code delivered when the user targeted for a tell
* notification is not online. */
public static final String USER_NOT_ONLINE = "m.user_not_online";
@@ -1,5 +1,5 @@
//
// $Id: ChatProvider.java,v 1.10 2002/04/30 17:27:30 mdb Exp $
// $Id: ChatProvider.java,v 1.11 2002/07/22 22:26:26 ray Exp $
package com.threerings.crowd.chat;
@@ -83,12 +83,36 @@ public class ChatProvider
*/
public static void sendChatMessage (
int placeOid, String speaker, String bundle, String message)
{
sendChatMessage(
placeOid, speaker, bundle, message, ChatCodes.DEFAULT_MODE);
}
/**
* Sends a chat notification to the specified place object originating
* with the specified speaker (the speaker optionally being a server
* entity that wishes to fake a "speak" message) and with the supplied
* message content.
*
* @param placeOid the place to which to deliver the chat message.
* @param speaker the username of the user that generated the message
* (or some special speaker name for server messages).
* @param bundle null when the message originates from a real human,
* the bundle identifier that will be used by the client to translate
* the message text when the message originates from a server entity
* "faking" a chat message.
* @param message the text of the chat message.
* @param mode the mode of the message, @see ChatCodes.DEFAULT_MODE
*/
public static void sendChatMessage (
int placeOid, String speaker, String bundle, String message,
String mode)
{
Object[] outargs = null;
if (bundle == null) {
outargs = new Object[] { speaker, message };
outargs = new Object[] { speaker, message, mode };
} else {
outargs = new Object[] { speaker, bundle, message };
outargs = new Object[] { speaker, bundle, message, mode };
}
MessageEvent nevt = new MessageEvent(
placeOid, ChatService.SPEAK_NOTIFICATION, outargs);