From e7bd54fa2d9b904db91dc010d4e3210f285ebb14 Mon Sep 17 00:00:00 2001 From: Par Winzell Date: Tue, 7 Sep 2010 20:08:25 +0000 Subject: [PATCH] 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 --- .../crowd/chat/server/ChatChannelManager.java | 56 ++++++++++--------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/src/java/com/threerings/crowd/chat/server/ChatChannelManager.java b/src/java/com/threerings/crowd/chat/server/ChatChannelManager.java index f9187ad4e..950b7e75d 100644 --- a/src/java/com/threerings/crowd/chat/server/ChatChannelManager.java +++ b/src/java/com/threerings/crowd/chat/server/ChatChannelManager.java @@ -21,7 +21,12 @@ 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.collect.Iterables; @@ -32,24 +37,26 @@ import com.google.inject.Inject; import com.samskivert.util.ArrayIntSet; 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.presents.annotation.AnyThread; +import com.threerings.presents.client.InvocationService; 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.NodeObject; import com.threerings.presents.peer.server.PeerManager; -import com.threerings.presents.server.InvocationManager; -import com.threerings.presents.server.PresentsDObjectMgr; +import com.threerings.presents.peer.server.PeerManager.NodeRequest; +import com.threerings.presents.peer.server.NodeRequestsListener; import com.threerings.crowd.chat.data.ChatChannel; import com.threerings.crowd.chat.data.ChatCodes; 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.CrowdCodes; import com.threerings.crowd.peer.data.CrowdClientInfo; @@ -105,26 +112,21 @@ public abstract class ChatChannelManager @AnyThread public void collectChatHistory (Name user, final ResultListener lner) { - _peerMan.invokeNodeRequest ( - new ChatCollectionRequest(user), new NodeRequestsListener>() - { - public void requestsProcessed (NodeRequestsResult> requestResult) - { - ChatHistoryResult result = new ChatHistoryResult(); - result.failedNodes = requestResult.getNodeErrors().keySet(); - result.history = Lists.newArrayList(); - for (Map.Entry> entry : requestResult.getNodeResults().entrySet()) { - result.history.addAll(entry.getValue()); + NodeRequestsListener> listener = + new NodeRequestsListener>() { + public void requestsProcessed (NodeRequestsResult> rRes) { + ChatHistoryResult chRes = new ChatHistoryResult(); + chRes.failedNodes = rRes.getNodeErrors().keySet(); + chRes.history = Lists.newArrayList( + Iterables.concat(rRes.getNodeResults().values())); + Collections.sort(chRes.history, SORT_BY_TIMESTAMP); + lner.requestCompleted(chRes); } - Collections.sort(result.history, SORT_BY_TIMESTAMP); - lner.requestCompleted(result); - } - - public void requestFailed (String cause) - { - lner.requestFailed(new InvocationException(cause)); - } - }); + public void requestFailed (String cause) { + lner.requestFailed(new InvocationException(cause)); + } + }; + _peerMan.invokeNodeRequest(new ChatCollectionRequest(user), listener); } // from interface ChannelSpeakProvider