@ AnyThread public void collectChatHistory ( final Name user , final ResultListener < ChatHistoryResult > lner ) { _peerMan . invokeNodeRequest ( new NodeRequest ( ) { public boolean isApplicable ( NodeObject nodeobj ) { return true ; // poll all nodes } @ Override protected void execute ( InvocationService . ResultListener listener ) { // find all the UserMessages for the given user and send them back listener . requestProcessed ( Lists . newArrayList ( Iterables . filter ( _chatHistory . get ( user ) , IS_USER_MESSAGE ) ) ) ; } @ Inject protected transient ChatHistory _chatHistory ; } , new NodeRequestsListener < List < ChatHistory . Entry > > ( ) { public void requestsProcessed ( NodeRequestsResult < List < ChatHistory . Entry > > 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 ) ; } public void requestFailed ( String cause ) { lner . requestFailed ( new InvocationException ( cause ) ) ; } } ) ; }
Collects all chat messages heard by the given user on all peers .