Fix up imports, cuddle braces, use fancy .concat().

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6145 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Par Winzell
2010-09-07 20:08:25 +00:00
parent 73e44953d7
commit e7bd54fa2d
@@ -21,7 +21,12 @@
package com.threerings.crowd.chat.server; package com.threerings.crowd.chat.server;
import java.util.*; import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
@@ -32,24 +37,26 @@ import com.google.inject.Inject;
import com.samskivert.util.ArrayIntSet; import com.samskivert.util.ArrayIntSet;
import com.samskivert.util.ResultListener; import com.samskivert.util.ResultListener;
import com.threerings.crowd.chat.server.SpeakUtil.ChatHistoryEntry;
import com.threerings.presents.client.InvocationService;
import com.threerings.presents.peer.server.PeerManager.NodeRequest;
import com.threerings.presents.peer.server.NodeRequestsListener;
import com.threerings.presents.server.InvocationException;
import com.threerings.util.Name; import com.threerings.util.Name;
import com.threerings.presents.annotation.AnyThread; import com.threerings.presents.annotation.AnyThread;
import com.threerings.presents.client.InvocationService;
import com.threerings.presents.data.ClientObject; import com.threerings.presents.data.ClientObject;
import com.threerings.presents.server.InvocationException;
import com.threerings.presents.server.InvocationManager;
import com.threerings.presents.server.PresentsDObjectMgr;
import com.threerings.presents.peer.data.ClientInfo; import com.threerings.presents.peer.data.ClientInfo;
import com.threerings.presents.peer.data.NodeObject; import com.threerings.presents.peer.data.NodeObject;
import com.threerings.presents.peer.server.PeerManager; import com.threerings.presents.peer.server.PeerManager;
import com.threerings.presents.server.InvocationManager; import com.threerings.presents.peer.server.PeerManager.NodeRequest;
import com.threerings.presents.server.PresentsDObjectMgr; import com.threerings.presents.peer.server.NodeRequestsListener;
import com.threerings.crowd.chat.data.ChatChannel; import com.threerings.crowd.chat.data.ChatChannel;
import com.threerings.crowd.chat.data.ChatCodes; import com.threerings.crowd.chat.data.ChatCodes;
import com.threerings.crowd.chat.data.UserMessage; import com.threerings.crowd.chat.data.UserMessage;
import com.threerings.crowd.chat.server.SpeakUtil.ChatHistoryEntry;
import com.threerings.crowd.data.BodyObject; import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.CrowdCodes; import com.threerings.crowd.data.CrowdCodes;
import com.threerings.crowd.peer.data.CrowdClientInfo; import com.threerings.crowd.peer.data.CrowdClientInfo;
@@ -105,26 +112,21 @@ public abstract class ChatChannelManager
@AnyThread @AnyThread
public void collectChatHistory (Name user, final ResultListener<ChatHistoryResult> lner) public void collectChatHistory (Name user, final ResultListener<ChatHistoryResult> lner)
{ {
_peerMan.invokeNodeRequest ( NodeRequestsListener<List<ChatHistoryEntry>> listener =
new ChatCollectionRequest(user), new NodeRequestsListener<List<ChatHistoryEntry>>() new NodeRequestsListener<List<ChatHistoryEntry>>() {
{ public void requestsProcessed (NodeRequestsResult<List<ChatHistoryEntry>> rRes) {
public void requestsProcessed (NodeRequestsResult<List<ChatHistoryEntry>> requestResult) ChatHistoryResult chRes = new ChatHistoryResult();
{ chRes.failedNodes = rRes.getNodeErrors().keySet();
ChatHistoryResult result = new ChatHistoryResult(); chRes.history = Lists.newArrayList(
result.failedNodes = requestResult.getNodeErrors().keySet(); Iterables.concat(rRes.getNodeResults().values()));
result.history = Lists.newArrayList(); Collections.sort(chRes.history, SORT_BY_TIMESTAMP);
for (Map.Entry<String, List<ChatHistoryEntry>> entry : requestResult.getNodeResults().entrySet()) { lner.requestCompleted(chRes);
result.history.addAll(entry.getValue());
} }
Collections.sort(result.history, SORT_BY_TIMESTAMP); public void requestFailed (String cause) {
lner.requestCompleted(result); lner.requestFailed(new InvocationException(cause));
} }
};
public void requestFailed (String cause) _peerMan.invokeNodeRequest(new ChatCollectionRequest(user), listener);
{
lner.requestFailed(new InvocationException(cause));
}
});
} }
// from interface ChannelSpeakProvider // from interface ChannelSpeakProvider