one to one chat history with open fire and smack

穿精又带淫゛_ 提交于 2019-12-11 14:06:42

问题


I have installed open fire in my system and by using postman tool i am able to create the user and by using smack i can able to send the message to other user also.. but the problem is that i dont know that how to fetch the chat history between two users..it means if i sent the from and to user names i need to fetch the previous chat history. I am able to see the chat history in the open fire servers--> archieving folder.. But i am not getting that how to fetch the chat history. Is there any Rest API's are available to fetch the chat history between two users..

Please provide any possible solution

Thank You

This is the chat history that I can see


回答1:


If you want use get chat history from openfire with smack:

  1. As you already done, enable MAM (XEP-0313) by installing MonitoringService plugin in openfire.
  2. Now from openfire server go to: Server>Archiving>Archiving Settings and check "Archive one-to-one chats" and "Archive group chats" and save click "update setting".
  3. From now on any chats will be saved on openfire. Start a new chat with someone and reinstall your android app.
  4. MAM is a part of "smack-experimental". So you must add this line to your gradle:

    implementation 'org.igniterealtime.smack:smack-extensions:4.2.2
    
  5. After a successful connection and authorization for one of them, you can get chat history page by page or as you need with this code:

    MamManager manager = MamManager.getInstanceFor(connection);
    MamManager.MamQueryResult r = manager.mostRecentPage([userBareJID], [numberOfMessages]);
    if (r.forwardedMessages.size() >= 1) //printing first of them
    {
        Message message = (Message) r.forwardedMessages.get(0).getForwardedStanza();
        Log.i("mam", "message received" + message.getBody());
    }
    


来源:https://stackoverflow.com/questions/51170390/one-to-one-chat-history-with-open-fire-and-smack

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!