Monday, February 26, 2018

Chat history forwardedMessages is empty ArrayList

Leave a Comment

I am trying to implement a java smack client interacting with Openfire server. I have added the plugin for Monitoring service, also enabled archiving. Now I can see the chat history in the openFire Admin Console. I would like to do the same using Smack. This is the code I have written.

XMPPTCPConnection connection = connectToXMPP(Constants.XMPPADMINUSERNAME, Constants.XMPPADMINPWD ,Constants.XMPPDOMAIN);  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("userlocal1@125.99.44.122");     form.addField(formField);     boolean isSupported = mamManager.isSupported();     // "" empty string for before     RSMSet rsmSet = new RSMSet(maxResults, "", RSMSet.PageDirection.before);     MamManager.MamQueryResult mamQueryResult = mamManager.page(form, rsmSet);    // MamManager.MamQueryResult mamQueryResult1 = mamManager.queryArchive(JidCreate.from("userlocal1@125.99.44.122"));     return mamQueryResult;  } catch (Exception e) {     e.printStackTrace(); } return null; 

Now the problem is the forwardedMessages ArrayList is always null. What am I doing wrong?? isSupported is true and I can see the chathistory on admin console… Please guide…

1 Answers

Answers 1

I notice that you're trying to get the last few archived messages, which makes sense. I'm not sure if your 'before' value should be empty though. For testing purposes, try reversing the page direction, and see if you can get the first/oldest few archived messages.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment