8
votes

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
Why do you think server keeps such history?Okas
@OKas Currently i have installed monitory plugin which is storing chat conversation at sever side but i don't know how to retrievingMahi
I'm afraid standard xmpp protocol does not provide what you want. You have to implement some custom solution for accessing monitoring plugin data.Okas
@Okas So we need to create custom API's for retrieve user's chat history ??Mahi
I found specification XEP-0136: Message Archiving xmpp.org/extensions/xep-0136.html . This specification is able to send message history to client and in openfire it is already implemented as Monitoring plugin.Mahi

1 Answers

0
votes
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());
 }
}