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:
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;
}
回答3:
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?".
回答4:
Finally I got the answer. Archive Messaging features are currently not implemented in Smack library.
https://community.igniterealtime.org/message/249993#249993