Added a new type of chat message: a UserSystemMessage is a system message

triggered by the activity of another user. The other username is provided
so that the message can be muted if desired.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3770 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2005-11-29 19:33:04 +00:00
parent 9a42f14028
commit dc3cf4aa28
2 changed files with 56 additions and 5 deletions
@@ -60,6 +60,7 @@ import com.threerings.crowd.chat.data.ChatMessage;
import com.threerings.crowd.chat.data.SystemMessage;
import com.threerings.crowd.chat.data.TellFeedbackMessage;
import com.threerings.crowd.chat.data.UserMessage;
import com.threerings.crowd.chat.data.UserSystemMessage;
/**
* The chat director is the client side coordinator of all chat related
@@ -656,17 +657,27 @@ public class ChatDirector extends BasicDirector
String localtype = getLocalType(event.getTargetOid());
String message = msg.message;
String autoResponse = null;
Name speaker = null;
byte mode = (byte) -1;
// if the message came from a user, make sure we want to hear it
// figure out if the message was triggered by another user
if (msg instanceof UserMessage) {
UserMessage umsg = (UserMessage)msg;
Name speaker = umsg.speaker;
speaker = umsg.speaker;
mode = umsg.mode;
} else if (msg instanceof UserSystemMessage) {
speaker = ((UserSystemMessage) msg).speaker;
}
// if there was an originating speaker, see if we want to hear it
if (speaker != null) {
if ((message = filter(message, speaker, false)) == null) {
return;
}
if (USER_CHAT_TYPE.equals(localtype) &&
umsg.mode == ChatCodes.DEFAULT_MODE) {
mode == ChatCodes.DEFAULT_MODE) {
// if it was a tell, add the speaker as a chatter
addChatter(speaker);
@@ -687,9 +698,8 @@ public class ChatDirector extends BasicDirector
// if we auto-responded, report as much
if (autoResponse != null) {
Name teller = ((UserMessage) msg).speaker;
String amsg = MessageBundle.tcompose(
"m.auto_responded", teller, autoResponse);
"m.auto_responded", speaker, autoResponse);
displayFeedback(_bundle, amsg);
}
}
@@ -0,0 +1,41 @@
//
// $Id$
package com.threerings.crowd.chat.data;
import com.threerings.util.Name;
/**
* 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 Name speaker;
/** Suitable for unserialization. */
public UserSystemMessage ()
{
}
/**
* Construct a INFO-level UserSystemMessage.
*/
public UserSystemMessage (Name sender, String message, String bundle)
{
this(sender, message, bundle, INFO);
}
/**
* Construct a UserSystemMessage.
*/
public UserSystemMessage (Name sender, String message, String bundle,
byte attentionLevel)
{
super(message, bundle, attentionLevel);
this.speaker = sender;
}
}