public class ChatDirector extends BasicDirector implements ChatCodes, LocationObserver, MessageListener
| Modifier and Type | Class and Description |
|---|---|
static interface |
ChatDirector.ChatterObserver
An interface to receive information about the
MAX_CHATTERS most recent users that
we've been chatting with. |
static interface |
ChatDirector.ChatterValidator
An interface for those who would like to validate whether usernames may be added to the
chatter list.
|
static class |
ChatDirector.CommandHandler
Used to implement a slash command (e.g.
|
BROADCAST_ACCESS, BROADCAST_MODE, CHAT_ACCESS, CHAT_CHANNEL_NOTIFICATION, CHAT_NOTIFICATION, DEFAULT_IDLE_TIME, DEFAULT_MODE, EMOTE_MODE, IDLE_TIME_KEY, LAST_MODE, PLACE_CHAT_TYPE, SHOUT_MODE, SUCCESS, THINK_MODE, USER_CHAT_TYPE, USER_DISCONNECTED, USER_NOT_ONLINE, XLATE_MODESACCESS_DENIED, E_ACCESS_DENIED, E_INTERNAL_ERROR, GLOBAL_GROUP, INTERNAL_ERROR| Constructor and Description |
|---|
ChatDirector(CrowdContext ctx,
String bundle)
Creates a chat director and initializes it with the supplied context.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAuxiliarySource(DObject source,
String localtype)
Adds an additional object via which chat messages may arrive.
|
boolean |
addChatDisplay(ChatDisplay display)
Adds the supplied chat display to the end of the chat display list.
|
boolean |
addChatFilter(ChatFilter filter)
Adds the specified chat filter to the list of filters.
|
boolean |
addChatterObserver(ChatDirector.ChatterObserver co)
Adds an observer that watches the chatters list, and updates it immediately.
|
void |
clearCommandHistory()
Clear the chat command history.
|
void |
clearDisplays()
Requests that all chat displays clear their contents.
|
void |
clientDidLogoff(Client client)
Called after the client has been logged off of the server and has disconnected.
|
void |
clientDidLogon(Client client)
Called after the client successfully connected to and authenticated with the server.
|
void |
clientObjectDidChange(Client client)
For systems that allow switching screen names after logon, this method is called whenever a
screen name change takes place to report that the client object has been replaced to
potential client-side subscribers.
|
void |
dispatchMessage(ChatMessage message,
String localType)
Dispatches the provided message to our chat displays.
|
void |
displayAttention(String bundle,
String message)
Display a system ATTENTION message as if it had come from the server.
|
void |
displayFeedback(String bundle,
String message)
Display a system FEEDBACK message as if it had come from the server.
|
void |
displayInfo(String bundle,
String message)
Display a system INFO message as if it had come from the server.
|
void |
displayInfo(String bundle,
String message,
String localtype)
Display a system INFO message as if it had come from the server.
|
String |
filter(String msg,
Name otherUser,
boolean outgoing)
Run a message through all the currently registered filters.
|
String |
getCommandHistory(int index)
Get the chat history entry at the specified index, with 0 being the oldest.
|
int |
getCommandHistorySize()
Return the current size of the history.
|
HistoryList |
getHistory()
Returns the history list containing a trailing window of messages that have passed through
this chat director.
|
void |
locationChangeFailed(int placeId,
String reason)
This is called on all location observers when a location change
request is rejected by the server or fails for some other reason.
|
void |
locationDidChange(PlaceObject place)
Called when we have switched to a new location.
|
boolean |
locationMayChange(int placeId)
Called when someone has requested that we switch to a new location.
|
void |
messageReceived(MessageEvent event)
Called when an message event has been dispatched on an object.
|
String |
mogrifyChat(String text)
Runs the supplied message through the various chat mogrifications.
|
void |
pushChatDisplay(ChatDisplay display)
Adds the supplied chat display to the front of the chat display list.
|
void |
registerCommandHandler(com.threerings.util.MessageBundle msg,
String command,
ChatDirector.CommandHandler handler)
Registers a chat command handler.
|
void |
removeAuxiliarySource(DObject source)
Removes a previously added auxiliary chat source.
|
boolean |
removeChatDisplay(ChatDisplay display)
Removes the specified chat display from the chat display list.
|
boolean |
removeChatFilter(ChatFilter filter)
Removes the specified chat filter from the list of chat filter.
|
boolean |
removeChatterObserver(ChatDirector.ChatterObserver co)
Removes an observer from the list of chatter observers.
|
void |
requestBroadcast(String message)
Requests to send a site-wide broadcast message.
|
String |
requestChat(SpeakService speakSvc,
String text,
boolean record)
Parses and delivers the supplied chat message.
|
void |
requestSpeak(SpeakService speakService,
String message,
byte mode)
Requests that a speak message with the specified mode be generated and delivered via the
supplied speak service instance (which will be associated with a particular "speak
object").
|
<T extends Name> |
requestTell(T target,
String msg,
ResultListener<T> rl)
Requests that a tell message be delivered to the specified target user.
|
void |
setAwayMessage(String message)
Configures a message that will be automatically reported to anyone that sends a tell message
to this client to indicate that we are busy or away from the keyboard.
|
void |
setChatterValidator(ChatDirector.ChatterValidator validator)
Sets the validator that decides if a username is valid to be added to the chatter list, or
null if no such filtering is desired.
|
void |
setMogrifyChat(boolean mogrifyChat)
Enables or disables the chat mogrifier.
|
clientWillLogon, isAvailableInStandalone, setAvailableInStandalonepublic ChatDirector(CrowdContext ctx, String bundle)
bundle - the message bundle from which we obtain our chat-related translation strings.public void pushChatDisplay(ChatDisplay display)
public boolean addChatDisplay(ChatDisplay display)
public boolean removeChatDisplay(ChatDisplay display)
public boolean addChatFilter(ChatFilter filter)
public boolean removeChatFilter(ChatFilter filter)
public boolean addChatterObserver(ChatDirector.ChatterObserver co)
public boolean removeChatterObserver(ChatDirector.ChatterObserver co)
public void setChatterValidator(ChatDirector.ChatterValidator validator)
public void setMogrifyChat(boolean mogrifyChat)
x.mogrifies and x.transforms translation
properties.public void registerCommandHandler(com.threerings.util.MessageBundle msg,
String command,
ChatDirector.CommandHandler handler)
msg - the message bundle via which the slash command will be translated (as
c.command). If no translation exists the command will be
/command.command - the name of the command that will be used to invoke this handler (e.g.
tell if the command will be invoked as /tell).handler - the chat command handler itself.public int getCommandHistorySize()
public String getCommandHistory(int index)
public void clearCommandHistory()
public void clearDisplays()
public void displayInfo(String bundle, String message)
public void displayInfo(String bundle, String message, String localtype)
public void displayFeedback(String bundle, String message)
public void displayAttention(String bundle, String message)
public void dispatchMessage(ChatMessage message, String localType)
public String requestChat(SpeakService speakSvc, String text, boolean record)
speakSvc - the SpeakService representing the target dobj of the speak or null if we
should speak in the "default" way.text - the text to be parsed and sent.record - if text is a command, should it be added to the history?ChatCodes#SUCCESS if the message was parsed and sent correctly, a
translatable error string if there was some problem.public void requestSpeak(SpeakService speakService, String message, byte mode)
ChatFilters (and
possibly vetoed) before being dispatched.speakService - the speak service to use when generating the speak request or null if we
should speak in the current "place".message - the contents of the speak message.mode - a speech mode that will be interpreted by the ChatDisplay
implementations that eventually display this speak message.public void requestBroadcast(String message)
message - the contents of the message.public <T extends Name> void requestTell(T target, String msg, ResultListener<T> rl)
target - the username of the user to which the tell message should be delivered.msg - the contents of the tell message.rl - an optional result listener if you'd like to be notified of success or failure.public void setAwayMessage(String message)
public void addAuxiliarySource(DObject source, String localtype)
localtype - a type to be associated with all chat messages that arrive on the specified
DObject.public void removeAuxiliarySource(DObject source)
public HistoryList getHistory()
public String filter(String msg, Name otherUser, boolean outgoing)
public String mogrifyChat(String text)
public boolean locationMayChange(int placeId)
LocationObserverlocationMayChange in interface LocationObserverpublic void locationDidChange(PlaceObject place)
LocationObserverlocationDidChange in interface LocationObserverplace - the place object that represents the new location or
null if we have switched to no location.public void locationChangeFailed(int placeId,
String reason)
LocationObserverlocationChangeFailed in interface LocationObserverplaceId - the place id to which we attempted to relocate, but
failed.reason - the reason code that explains why the location change
request was rejected or otherwise failed.public void messageReceived(MessageEvent event)
MessageListenermessageReceived in interface MessageListenerevent - The event that was dispatched on the object.public void clientDidLogon(Client client)
SessionObserverclientDidLogon in interface SessionObserverclientDidLogon in class BasicDirectorpublic void clientObjectDidChange(Client client)
SessionObserverclientObjectDidChange in interface SessionObserverclientObjectDidChange in class BasicDirectorpublic void clientDidLogoff(Client client)
SessionObserverclientDidLogoff in interface SessionObserverclientDidLogoff in class BasicDirectorCopyright © 2015. All rights reserved.