Add channel-based communications to the chat history logs as well. This groud work for msoy issue 286, which has probably been around since the channel system was added.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5990 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -34,6 +34,9 @@ public class UserMessage extends ChatMessage
|
|||||||
/** The mode of the message. @see ChatCodes.DEFAULT_MODE */
|
/** The mode of the message. @see ChatCodes.DEFAULT_MODE */
|
||||||
public byte mode;
|
public byte mode;
|
||||||
|
|
||||||
|
/** The channel of the message, or null if not set. */
|
||||||
|
public ChatChannel channel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For unserialization.
|
* For unserialization.
|
||||||
*/
|
*/
|
||||||
@@ -41,25 +44,33 @@ public class UserMessage extends ChatMessage
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct a user message.
|
|
||||||
*/
|
|
||||||
public UserMessage (Name speaker, String bundle, String message, byte mode)
|
|
||||||
{
|
|
||||||
super(message, bundle);
|
|
||||||
this.speaker = speaker;
|
|
||||||
this.mode = mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a user message for a player originated tell (which has no bundle and is in the
|
* Constructs a user message for a player originated tell (which has no bundle and is in the
|
||||||
* default mode).
|
* default mode).
|
||||||
*/
|
*/
|
||||||
public UserMessage (Name speaker, String message)
|
public UserMessage (Name speaker, String message)
|
||||||
{
|
{
|
||||||
super(message, null);
|
this(speaker, null, message, ChatCodes.DEFAULT_MODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a user message.
|
||||||
|
*/
|
||||||
|
public UserMessage (Name speaker, String bundle, String message, byte mode)
|
||||||
|
{
|
||||||
|
this(null, speaker, bundle, message, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a user message that was spoken using the channel system.
|
||||||
|
*/
|
||||||
|
public UserMessage (
|
||||||
|
ChatChannel channel, Name speaker, String bundle, String message, byte mode)
|
||||||
|
{
|
||||||
|
super(message, bundle);
|
||||||
|
this.channel = channel;
|
||||||
this.speaker = speaker;
|
this.speaker = speaker;
|
||||||
this.mode = ChatCodes.DEFAULT_MODE;
|
this.mode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public abstract class ChatChannelManager
|
|||||||
public void speak (ClientObject caller, final ChatChannel channel, String message, byte mode)
|
public void speak (ClientObject caller, final ChatChannel channel, String message, byte mode)
|
||||||
{
|
{
|
||||||
final UserMessage umsg = new UserMessage(
|
final UserMessage umsg = new UserMessage(
|
||||||
((BodyObject)caller).getVisibleName(), null, message, mode);
|
intern(channel), ((BodyObject)caller).getVisibleName(), null, message, mode);
|
||||||
|
|
||||||
// if we're hosting this channel, dispatch it directly
|
// if we're hosting this channel, dispatch it directly
|
||||||
if (_channels.containsKey(channel)) {
|
if (_channels.containsKey(channel)) {
|
||||||
@@ -169,6 +169,7 @@ public abstract class ChatChannelManager
|
|||||||
{
|
{
|
||||||
// map the participants of our now resolved channel
|
// map the participants of our now resolved channel
|
||||||
ChannelInfo info = new ChannelInfo();
|
ChannelInfo info = new ChannelInfo();
|
||||||
|
info.channel = channel;
|
||||||
info.participants = parts;
|
info.participants = parts;
|
||||||
_channels.put(channel, info);
|
_channels.put(channel, info);
|
||||||
|
|
||||||
@@ -243,6 +244,7 @@ public abstract class ChatChannelManager
|
|||||||
for (int bodyId : bodyIds) {
|
for (int bodyId : bodyIds) {
|
||||||
BodyObject bobj = getBodyObject(bodyId);
|
BodyObject bobj = getBodyObject(bodyId);
|
||||||
if (bobj != null && shouldDeliverSpeak(channel, message, bobj)) {
|
if (bobj != null && shouldDeliverSpeak(channel, message, bobj)) {
|
||||||
|
SpeakUtil.recordToChatHistory(message, bobj.username);
|
||||||
bobj.postMessage(ChatCodes.CHAT_CHANNEL_NOTIFICATION, channel, message);
|
bobj.postMessage(ChatCodes.CHAT_CHANNEL_NOTIFICATION, channel, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -275,6 +277,19 @@ public abstract class ChatChannelManager
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a widely referenced instance equivalent to the given channel, if one is available.
|
||||||
|
* This reduces memory usage since clients send new channel instances with each message.
|
||||||
|
*/
|
||||||
|
protected ChatChannel intern (ChatChannel channel)
|
||||||
|
{
|
||||||
|
ChannelInfo chinfo = _channels.get(channel);
|
||||||
|
if (chinfo != null) {
|
||||||
|
return chinfo.channel;
|
||||||
|
}
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a speaker's visible name into a unique integer id. This is not the oid for this
|
* Converts a speaker's visible name into a unique integer id. This is not the oid for this
|
||||||
* speaker but rather a persistent integer identifier that can be passed between servers and
|
* speaker but rather a persistent integer identifier that can be passed between servers and
|
||||||
@@ -371,6 +386,9 @@ public abstract class ChatChannelManager
|
|||||||
/** Contains metadata for a particular channel. */
|
/** Contains metadata for a particular channel. */
|
||||||
protected static class ChannelInfo
|
protected static class ChannelInfo
|
||||||
{
|
{
|
||||||
|
/** The channel this info is for. */
|
||||||
|
public ChatChannel channel;
|
||||||
|
|
||||||
/** The body ids of the participants of this channel. */
|
/** The body ids of the participants of this channel. */
|
||||||
public IntSet participants;
|
public IntSet participants;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user