gpt4 book ai didi

XMPP 按最新消息查询存档

转载 作者:行者123 更新时间:2023-12-02 13:59:16 25 4
gpt4 key购买 nike

我正在阅读http://xmpp.org/extensions/xep-0313.html向 Ejabberd 查询特定用户存档的消息。

这是我要发送的 xml:

<iq type='get' id='get_archive_user1'>
<query xmlns='urn:xmpp:mam:tmp'>
<with>user1@localhost</with>
<set xmlns='http://jabber.org/protocol/rsm'>
<max>20</max>
</set>
</query>
</iq>

我正确接收了前 20 条消息。要再次请求,我添加标签:

<after>(id in element "Last" from last request)</after>

这也工作得很好。我需要的是接收最后 20 条消息,而不是前 20 条消息。我怎样才能实现这个目标?

最佳答案

XEP-0313 Message Archive Management依靠XEP-0059 Result Set Management用于分页。

RSM规范解释how to get the last page in a Result Set :

The requesting entity MAY ask for the last page in a result set by including in its request an empty <before/> element, and the maximum number of items to return.

这意味着你需要添加一个空的<before/>结果集查询中的元素。

以下是基于 XEP-0313 版本 0.4 的示例,说明如何获取与给定用户的对话中的最后 20 条消息。查询限制由参数 max 定义(它定义了页面的大小)。

<iq type='set' id='q29302'>
  <query xmlns='urn:xmpp:mam:0'>
    <x xmlns='jabber:x:data' type='submit'>
      <field var='FORM_TYPE' type='hidden'>
        <value>urn:xmpp:mam:0</value>
      </field>
      <field var='with'>
        <value>juliet@capulet.lit</value>
      </field>
    </x>
    <set xmlns='http://jabber.org/protocol/rsm'>
<max>20</max>
<before/>
    </set>
  </query>
</iq>

关于XMPP 按最新消息查询存档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31828955/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com