com.threerings.crowd.chat.server
Class ChatHistory

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

public class ChatHistory
extends Object

Provides a server-wide history of chat messages.


Nested Class Summary
static class ChatHistory.Entry
          Recorded parcel of chat for historical purposes, maintained by record(ChatChannel, UserMessage, Name...), get(Name), and clear(Name).
 
Field Summary
protected  Map<Name,List<ChatHistory.Entry>> _histories
          Recent chat history for the server.
protected  Set<Name> _holds
          Names we will hold for.
protected  PresentsDObjectMgr _omgr
           
static long HISTORY_EXPIRATION
          The amount of time before chat history becomes... history.
 
Constructor Summary
ChatHistory()
          Creates a new chat history, automatically registering a message observer with SpeakUtil.
 
Method Summary
 void clear(Name username)
          Clears the chat history for the specified user.
 List<ChatHistory.Entry> get(Name username)
          Returns a list of ChatHistory.Entry objects, one for each message to which this user has been privy in the recent past.
protected  List<ChatHistory.Entry> getList(Name username)
          Returns this user's chat history, creating one if necessary.
 void hold(Name username)
          Causes the chat history for the given user to be held briefly after the clear(com.threerings.util.Name) call so that session observers can grab it.
protected  void prune(long now, List<ChatHistory.Entry> history)
          Prunes all messages from this history which are expired.
 void record(ChatChannel channel, UserMessage msg, Name... usernames)
          Records the specified channel and message to the specified users' chat histories.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HISTORY_EXPIRATION

public static final long HISTORY_EXPIRATION
The amount of time before chat history becomes... history.

See Also:
Constant Field Values

_histories

protected Map<Name,List<ChatHistory.Entry>> _histories
Recent chat history for the server.


_holds

protected Set<Name> _holds
Names we will hold for.


_omgr

@Inject
protected PresentsDObjectMgr _omgr
Constructor Detail

ChatHistory

public ChatHistory()
Creates a new chat history, automatically registering a message observer with SpeakUtil.

Method Detail

get

public List<ChatHistory.Entry> get(Name username)
Returns a list of ChatHistory.Entry objects, one for each message to which this user has been privy in the recent past. If the given name implements KeepNoHistory, null is returned.


clear

public void clear(Name username)
Clears the chat history for the specified user.


record

public void record(ChatChannel channel,
                   UserMessage msg,
                   Name... usernames)
Records the specified channel and message to the specified users' chat histories. If ChatMessage.timestamp is not already filled in, it will be.


hold

public void hold(Name username)
Causes the chat history for the given user to be held briefly after the clear(com.threerings.util.Name) call so that session observers can grab it.


getList

protected List<ChatHistory.Entry> getList(Name username)
Returns this user's chat history, creating one if necessary. If the given name implements KeepNoHistory, null is returned.


prune

protected void prune(long now,
                     List<ChatHistory.Entry> history)
Prunes all messages from this history which are expired.