XMPP查询归档的最新消息

编程入门 行业动态 更新时间:2024-10-21 23:15:22
本文介绍了XMPP查询归档的最新消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在阅读 xmpp/extensions/xep-0313.html 向Ejabberd查询某个用户存档的邮件。

I'm reading xmpp/extensions/xep-0313.html to query Ejabberd for messages archived with a certain user.

这是我要发送的xml:

This is the xml that I'm sending:

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

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

I'm receiving the first 20 messages correctly. To request again I'm adding the tag:

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

,这也可以正常工作。我需要的是接收最后20条消息,而不是前20条消息。我该如何实现?

and this also work fine. What I need is to receive the last 20 messages, not the first 20 messages. How can I achieve this?

推荐答案

XEP-0313邮件存档管理依靠 XEP-0059结果集管理进行分页。

RSM规范说明了如何获取广告中的最后一页结果集:

请求实体可以通过在其请求中包括一个空的< before /> 元素,以及要返回的最大项目数。

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 /> 元素。

It means you need to add an empty <before/> element in your result set query.

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

Here is an example based on XEP-0313 version 0.4 on how to get the last 20 messages in a conversation with a given user. The query limit is defined by the parameter max (it defined the size of the pages).

<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='jabber/protocol/rsm'> <max>20</max> <before/>     </set>   </query> </iq>

更多推荐

XMPP查询归档的最新消息

本文发布于:2023-10-24 14:35:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1524194.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:最新消息   XMPP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!