本文介绍了一对一的聊天记录,轻松自如的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在系统中安装了明火,并且可以使用邮递员工具来创建用户,并且可以通过使用smack将消息发送给其他用户..但是问题是我不知道该怎么做来获取两个用户之间的聊天记录..这意味着,如果我将from和to发送到用户名,则需要获取以前的聊天记录.我可以在明火服务器->存档文件夹中查看聊天记录.但是我不知道如何获取聊天记录.是否有 Rest API可用于获取两个用户之间的聊天记录.

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

谢谢

这是我可以看到的聊天记录

This is the chat history that I can see

推荐答案

如果要使用,请从openfire中获取带有聊天记录的聊天记录:

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

  1. 已完成操作,请通过安装 openfire中的> MonitoringService 插件.
  2. 现在从openfire服务器中转到:服务器>存档>存档设置,然后选中存档一对一聊天"和存档群聊",然后单击更新设置"保存.
  3. 从现在开始,任何聊天都将保存在openfire上.与某人开始新的聊天,然后重新安装您的android应用.
  4. MAM是" smack-实验性".因此,您必须将此行添加到gradle:

  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

  • 在成功连接并授权其中一个后,您可以逐页获取聊天历史记录,也可以根据需要使用以下代码获取聊天记录:

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

  • 这篇关于一对一的聊天记录,轻松自如的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    09-01 19:38