com.threerings.crowd.chat.server
Class SpeakUtil

java.lang.Object
  extended by com.threerings.crowd.chat.server.SpeakUtil

public class SpeakUtil
extends Object

Provides the back-end of the chat speaking facilities.


Nested Class Summary
protected static class SpeakUtil.MessageMapper
          Used to note the recipients of a chat message.
static interface SpeakUtil.MessageObserver
          An interface used to notify external systems whenever a chat message is spoken by one user and heard by another.
protected static class SpeakUtil.MessageObserverOp
          Used to notify our SpeakUtil.MessageObservers.
 
Field Summary
protected static SpeakUtil.MessageMapper _messageMapper
          Used to note the recipients of a chat message.
protected static ObserverList<SpeakUtil.MessageObserver> _messageObs
          A list of SpeakUtil.MessageObservers.
protected static SpeakUtil.MessageObserverOp _messageOp
          Used to notify our SpeakUtil.MessageObservers.
 
Constructor Summary
SpeakUtil()
           
 
Method Summary
protected static void noteMessage(Name username, UserMessage msg)
          Notes that the specified user was privy to the specified message.
static void registerMessageObserver(SpeakUtil.MessageObserver obs)
          Registers a SpeakUtil.MessageObserver to be notified whenever a user-originated chat message is heard by another user.
static void removeMessageObserver(SpeakUtil.MessageObserver obs)
          Removes a registration made previously with registerMessageObserver(com.threerings.crowd.chat.server.SpeakUtil.MessageObserver).
static void sendAttention(DObject speakObj, String bundle, String message)
          Sends a system ATTENTION message notification to the specified object with the supplied message content.
static void sendFeedback(DObject speakObj, String bundle, String message)
          Sends a system FEEDBACK message notification to the specified object with the supplied message content.
static void sendInfo(DObject speakObj, String bundle, String message)
          Sends a system INFO message notification to the specified object with the supplied message content.
static void sendMessage(DObject speakObj, ChatMessage msg)
          Send the specified message on the specified object.
static void sendSpeak(DObject speakObj, Name speaker, String bundle, String message)
          Sends a speak 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.
static void sendSpeak(DObject speakObj, Name speaker, String bundle, String message, byte mode)
          Sends a speak 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.
protected static void sendSystem(DObject speakObj, String bundle, String message, byte level)
          Send the specified system message on the specified dobj.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_messageMapper

protected static SpeakUtil.MessageMapper _messageMapper
Used to note the recipients of a chat message.


_messageObs

protected static ObserverList<SpeakUtil.MessageObserver> _messageObs
A list of SpeakUtil.MessageObservers.


_messageOp

protected static SpeakUtil.MessageObserverOp _messageOp
Used to notify our SpeakUtil.MessageObservers.

Constructor Detail

SpeakUtil

public SpeakUtil()
Method Detail

registerMessageObserver

public static void registerMessageObserver(SpeakUtil.MessageObserver obs)
Registers a SpeakUtil.MessageObserver to be notified whenever a user-originated chat message is heard by another user.


removeMessageObserver

public static void removeMessageObserver(SpeakUtil.MessageObserver obs)
Removes a registration made previously with registerMessageObserver(com.threerings.crowd.chat.server.SpeakUtil.MessageObserver).


sendSpeak

public static void sendSpeak(DObject speakObj,
                             Name speaker,
                             String bundle,
                             String message)
Sends a speak 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.

Parameters:
speakObj - the object on which to generate the speak message.
speaker - the username of the user that generated the message (or some special speaker name for server messages).
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.
message - the text of the speak message.

sendSpeak

public static void sendSpeak(DObject speakObj,
                             Name speaker,
                             String bundle,
                             String message,
                             byte mode)
Sends a speak 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.

Parameters:
speakObj - the object on which to generate the speak message.
speaker - the username of the user that generated the message (or some special speaker name for server messages).
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.
message - the text of the speak message.
mode - the mode of the message, see ChatCodes.DEFAULT_MODE.

sendInfo

public static void sendInfo(DObject speakObj,
                            String bundle,
                            String message)
Sends a system INFO message notification to the specified object with the supplied message content. A system message is one that will be rendered where the speak messages are rendered, but in a way that makes it clear that it is a message from the server. Info messages are sent when something happens that was neither directly triggered by the user, nor requires direct action.

Parameters:
speakObj - the object on which to deliver the message.
bundle - the name of the localization bundle that should be used to translate this system message prior to displaying it to the client.
message - the text of the message.

sendFeedback

public static void sendFeedback(DObject speakObj,
                                String bundle,
                                String message)
Sends a system FEEDBACK message notification to the specified object with the supplied message content. A system message is one that will be rendered where the speak messages are rendered, but in a way that makes it clear that it is a message from the server. Feedback messages are sent in direct response to a user action, usually to indicate success or failure of the user's action.

Parameters:
speakObj - the object on which to deliver the message.
bundle - the name of the localization bundle that should be used to translate this system message prior to displaying it to the client.
message - the text of the message.

sendAttention

public static void sendAttention(DObject speakObj,
                                 String bundle,
                                 String message)
Sends a system ATTENTION message notification to the specified object with the supplied message content. A system message is one that will be rendered where the speak messages are rendered, but in a way that makes it clear that it is a message from the server. Attention messages are sent when something requires user action that did not result from direct action by the user.

Parameters:
speakObj - the object on which to deliver the message.
bundle - the name of the localization bundle that should be used to translate this system message prior to displaying it to the client.
message - the text of the message.

sendMessage

public static void sendMessage(DObject speakObj,
                               ChatMessage msg)
Send the specified message on the specified object.


noteMessage

protected static void noteMessage(Name username,
                                  UserMessage msg)
Notes that the specified user was privy to the specified message. If ChatMessage.timestamp is not already filled in, it will be.


sendSystem

protected static void sendSystem(DObject speakObj,
                                 String bundle,
                                 String message,
                                 byte level)
Send the specified system message on the specified dobj.