How to retrieve one to one chat history from Openf

2020-02-28 17:58发布

问题:

Please can anyone show me the exact code for retrieving a chat history from openfire server to android client application using asmack library and XMPP protocol? In my openfire server I was enable merged Monitoring service/Open archive service and all messages successfully stored into database. But I don't know how those messages (chat history) retrieve to my client application which is building in ANDROID. What type of chat I need is one-to-one user chat (not group chat).

I am success ed to getting group chat history with help of this but i want to retrieve one to one chat history

Please if anyone can write me a code, I'd be very grateful.

Thanks!

回答1:

public class XMPPManager implements PacketListener {
........

   void connect(){
   //Init connection configuration
       ......
   XMPPTCPConnection xmppTCPConnection = new XMPPTCPConnection(connectionBuilder.build());
   xmppTCPConnection .connect();
   xmppTCPConnection.addSyncStanzaListener(this, null);
 }

 @Override
 public void processStanza(Stanza packet) {
   //Log.d("Log","Body - " + message.getBody());
 }
}