How retrieve Chat History using Java Smack library from openfire server?

匿名 (未验证) 提交于 2019-12-03 02:49:01

问题:

After installing Open Archive plugin in the Openfire server I can see the chat conversation between two user from the openfire admin panel which is pretty easy and that is web based too. Now I want to retrive those conversation or chat history from chat client application(written in java) where I've used Smack library. I didn't found any helpfull resource for that. Any advice will be helpfull.

回答1:

Smack just implemented MAM feature [XEP 0313] but yet not released, hope to get it on next release if you want to use this feature build the smack library from source or you can use custom IQ to get archived messages from server.



回答2:

The solution you're looking for come under XMPP specification's XEP-0136 Message archiving but Smack has not implemented this features yet. but you can retrieve the message history from server using "custom-stanza" features provided by SMACK API. The following links describe how to send the custom stanza. "How retrieve Chat History using Java Smack library from openfire server?".



回答3:

It might be a late answer but now as SMACK API supports XEP-0136 and XEP-0313, so below code can help people landing to this page.

public MamManager.MamQueryResult getArchivedMessages(String jid, int maxResults) {          MamManager mamManager = MamManager.getInstanceFor(connection);         try {             DataForm form = new DataForm(DataForm.Type.submit);             FormField field = new FormField(FormField.FORM_TYPE);             field.setType(FormField.Type.hidden);             field.addValue(MamElements.NAMESPACE);             form.addField(field);              FormField formField = new FormField("with");             formField.addValue(jid);             form.addField(formField);              // "" empty string for before             RSMSet rsmSet = new RSMSet(maxResults, "", RSMSet.PageDirection.before);             MamManager.MamQueryResult mamQueryResult = mamManager.page(form, rsmSet);              return mamQueryResult;          } catch (Exception e) {             e.printStackTrace();         }         return null;     } 


回答4:

Finally I got the answer. Archive Messaging features are currently not implemented in Smack library.

https://community.igniterealtime.org/message/249993#249993



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