|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.crowd.chat.server.ChatChannelManager
public abstract class ChatChannelManager
Handles chat channel services.
| Nested Class Summary | |
|---|---|
protected static class |
ChatChannelManager.ChannelAction
Forwards a channel speak request from the server hosting the message originator to the server that is hosting the channel. |
protected static class |
ChatChannelManager.ChannelInfo
Contains metadata for a particular channel. |
static class |
ChatChannelManager.ChatHistoryResult
Value asynchronously returned by collectChatHistory(com.threerings.util.Name, com.samskivert.util.ResultListener after polling all peer nodes. |
| Field Summary | |
|---|---|
protected Map<ChatChannel,ChatChannelManager.ChannelInfo> |
_channels
A map of resolved channels to metadata records. |
protected ChatHistory |
_chatHistory
Used for recording chat history. |
protected BodyLocator |
_locator
Used for acquiring BodyObject references from Names and ClientObjects. |
protected CrowdPeerManager |
_peerMan
Provides peer services. |
protected Map<ChatChannel,List<UserMessage>> |
_resolving
Contains pending messages for all channels currently being resolved. |
protected static long |
IDLE_CHANNEL_CHECK_PERIOD
The period on which we check for idle channels. |
protected static long |
IDLE_CHANNEL_CLOSE_TIME
The amount of idle time (in milliseconds) after which we close a channel. |
protected static Predicate<ChatHistory.Entry> |
IS_USER_MESSAGE
|
protected static Comparator<ChatHistory.Entry> |
SORT_BY_TIMESTAMP
|
| Constructor Summary | |
|---|---|
protected |
ChatChannelManager(PresentsDObjectMgr omgr,
InvocationManager invmgr)
Creates our singleton manager and registers our invocation service. |
| Method Summary | |
|---|---|
void |
bodyAddedToChannel(ChatChannel channel,
int bodyId)
When a body becomes a member of a channel, this method should be called so that any server that happens to be hosting that channel can be told that the body in question is now a participant. |
void |
bodyRemovedFromChannel(ChatChannel channel,
int bodyId)
When a body loses channel membership, this method should be called so that any server that happens to be hosting that channel can be told that the body in question is now a participant. |
protected void |
closeIdleChannels()
Called periodically to check for and close any channels that have been idle too long. |
void |
collectChatHistory(Name user,
ResultListener<ChatChannelManager.ChatHistoryResult> lner)
Collects all chat messages heard by the given user on all peers. |
protected void |
deliverSpeak(ChatChannel channel,
UserMessage message,
int[] bodyIds)
Delivers the supplied chat channel message to the specified bodies. |
protected void |
dispatchSpeak(ChatChannel channel,
UserMessage message)
Requests that we dispatch the supplied message to all participants of the specified chat channel. |
protected void |
finishResolveAndDispatch(ChatChannel channel)
Resolves the participant set for the specified chat channel and dispatches all pending messages to the channel. |
protected abstract int |
getBodyId(Name speaker)
Converts a speaker's visible name into a unique integer id. |
protected abstract BodyObject |
getBodyObject(int bodyId)
Locates a body object from the given unique id. |
protected ChatChannel |
intern(ChatChannel channel)
Returns a widely referenced instance equivalent to the given channel, if one is available. |
protected void |
resolutionComplete(ChatChannel channel,
Set<Integer> parts)
This should be called when a channel's participant set has been resolved. |
protected void |
resolutionFailed(ChatChannel channel,
Exception cause)
This should be called if channel resolution fails. |
protected void |
resolveAndDispatch(ChatChannel channel)
Resolves the channel specified in the supplied action and then dispatches it. |
protected boolean |
shouldDeliverSpeak(ChatChannel channel,
UserMessage message,
BodyObject body)
Ratifies the delivery of the supplied chat channel message to the specified body. |
void |
speak(ClientObject caller,
ChatChannel channel,
String message,
byte mode)
Handles a ChannelSpeakService.speak(com.threerings.crowd.chat.data.ChatChannel, java.lang.String, byte) request. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final Predicate<ChatHistory.Entry> IS_USER_MESSAGE
protected static final Comparator<ChatHistory.Entry> SORT_BY_TIMESTAMP
protected Map<ChatChannel,List<UserMessage>> _resolving
protected Map<ChatChannel,ChatChannelManager.ChannelInfo> _channels
@Inject protected CrowdPeerManager _peerMan
@Inject protected BodyLocator _locator
@Inject protected ChatHistory _chatHistory
protected static final long IDLE_CHANNEL_CHECK_PERIOD
protected static final long IDLE_CHANNEL_CLOSE_TIME
| Constructor Detail |
|---|
@Inject
protected ChatChannelManager(PresentsDObjectMgr omgr,
InvocationManager invmgr)
| Method Detail |
|---|
public void bodyAddedToChannel(ChatChannel channel,
int bodyId)
public void bodyRemovedFromChannel(ChatChannel channel,
int bodyId)
public void collectChatHistory(Name user,
ResultListener<ChatChannelManager.ChatHistoryResult> lner)
public void speak(ClientObject caller,
ChatChannel channel,
String message,
byte mode)
ChannelSpeakProviderChannelSpeakService.speak(com.threerings.crowd.chat.data.ChatChannel, java.lang.String, byte) request.
speak in interface ChannelSpeakProviderprotected void resolveAndDispatch(ChatChannel channel)
protected void finishResolveAndDispatch(ChatChannel channel)
resolutionComplete(com.threerings.crowd.chat.data.ChatChannel, java.util.Set) or resolutionFailed(com.threerings.crowd.chat.data.ChatChannel, java.lang.Exception).
protected void resolutionComplete(ChatChannel channel,
Set<Integer> parts)
protected void resolutionFailed(ChatChannel channel,
Exception cause)
protected void dispatchSpeak(ChatChannel channel,
UserMessage message)
protected void deliverSpeak(ChatChannel channel,
UserMessage message,
int[] bodyIds)
protected void closeIdleChannels()
protected boolean shouldDeliverSpeak(ChatChannel channel,
UserMessage message,
BodyObject body)
protected ChatChannel intern(ChatChannel channel)
protected abstract int getBodyId(Name speaker)
getBodyObject(int). We
use this rather than names to avoid having to send (large) Name objects for every
channel participant to each individual peer that will be forwarding messages.
protected abstract BodyObject getBodyObject(int bodyId)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||