1
votes

I'm now developing an apps with message history retrieval based on XEP-0136 with Openfire Server.

I've read that message history retrieval can be combined with Result Set Management (RSM)-XEP-0059.

We can delimit the number of message retrieval request by setting max attribute of RSM like this:

<iq type='get' id='juliet1'>
  <list xmlns='urn:xmpp:archive'
        with='[email protected]'>
    <set xmlns='http://jabber.org/protocol/rsm'>
      <max>5</max>
    </set>
  </list>
</iq>

This should return the first 5 chat list from the top (ordered by chat time ascending).

My question is how to retrieve the last 5 chat list from the bottom, so I can get the latest chat message not the first time chat.

I've seen this Reversed RSM standard suggestion, like this:

<iq type='get' id='juliet1'>
  <list xmlns='urn:xmpp:archive'
        with='[email protected]'>
    <set xmlns='http://jabber.org/protocol/rsm'>
      <max>5</max>
      <before />
      <reversed />
    </set>
  </list>
</iq>

But this standard seems not yet implemented.

Thanks in advance

1

1 Answers

1
votes

Based on this, the stanza is like this:

<iq type='get' id='juliet1'>
  <list xmlns='urn:xmpp:archive'
        with='[email protected]'>
    <set xmlns='http://jabber.org/protocol/rsm'>
      <max>5</max>
      <before />
    </set>
  </list>
</iq>

You can retrieve the collection from bottom by RSM.

But seems Openfire message archiving plugin had some bugs with this RSM.

Reference: http://community.igniterealtime.org/message/230389#230389

So, the possible solution is getting count of my collection:

<iq type='get' id='juliet1'>
  <list xmlns='urn:xmpp:archive'
        with='[email protected]'>
    <set xmlns='http://jabber.org/protocol/rsm'>
      <max>0</max>
    </set>
  </list>
</iq>

It will return:

<iq xmlns='jabber:client' type='result' id='juliet1' to='admin@somehost'>
  <list xmlns='urn:xmpp:archive'>
    <set xmlns='http://jabber.org/protocol/rsm'>
      <count>10</count>
    </set>
   </list>
</iq>

And I select the collection by index:

<iq type='get' id='juliet1'>
  <list xmlns='urn:xmpp:archive'
        with='[email protected]'>
    <set xmlns='http://jabber.org/protocol/rsm'>
      <max>5</max>
      <index>4</index>
    </set>
  </list>
</iq>