获取发布者的离线消息
Posted
技术标签:
【中文标题】获取发布者的离线消息【英文标题】:get offline messages of publisher 【发布时间】:2012-12-07 14:28:28 【问题描述】:我已经使用 openfire
实现了 XEP-0060
pubsub,我能够在现有节点上发布消息,并且我还有其他订阅者可以获得这些发布的消息。
现在的问题是,我无法接收旧消息,我的意思是如果订阅者离线并且当他们重新在线时,我如何才能获得发布者很久以前发布的旧消息。
我的发布者发布的节点配置如下
<iq from="pubsub.example.com" type="result" id="meta1" to="lime@example.com/localhost">
<query xmlns="http://jabber.org/protocol/disco#info" node="mynode/loc">
<identity category="pubsub" type="leaf"/>
<feature var="http://jabber.org/protocol/pubsub"/>
<feature var="http://jabber.org/protocol/disco#info"/>
<x xmlns="jabber:x:data" type="result">
<field type="hidden" var="FORM_TYPE">
<value>http://jabber.org/protocol/pubsub#meta-data</value>
</field>
<field type="text-single" label="Short name for the node" var="pubsub#title">
<value/>
</field>
<field type="text-single" label="Description of the node" var="pubsub#description">
<value/>
</field>
<field type="boolean" label="Allow subscriptions to node" var="pubsub#subscribe">
<value>1</value>
</field>
<field type="boolean" label="New subscriptions require configuration" var="pubsub#subscription_required">
<value>0</value>
</field>
<field type="boolean" label="Deliver payloads with event notifications" var="pubsub#deliver_payloads">
<value>1</value>
</field>
<field type="boolean" label="Notify subscribers when the node configuration changes" var="pubsub#notify_config">
<value>1</value>
</field>
<field type="boolean" label="Notify subscribers when the node is deleted" var="pubsub#notify_delete">
<value>1</value>
</field>
<field type="boolean" label="Notify subscribers when items are removed from the node" var="pubsub#notify_retract">
<value>1</value>
</field>
<field type="boolean" label="Only deliver notifications to available users" var="pubsub#presence_based_delivery">
<value>0</value>
</field>
<field type="text-single" label="Type of payload data to be provided at this node" var="pubsub#type">
<value/>
</field>
<field type="text-single" label="Message body XSLT" var="pubsub#body_xslt">
<value/>
</field>
<field type="text-single" label="Payload XSLT" var="pubsub#dataform_xslt">
<value/>
</field>
<field type="list-single" label="Specify who may subscribe and retrieve items" var="pubsub#access_model">
<option>
<value>authorize</value>
</option>
<option>
<value>open</value>
</option>
<option>
<value>presence</value>
</option>
<option>
<value>roster</value>
</option>
<option>
<value>whitelist</value>
</option>
<value>open</value>
</field>
<field type="list-single" label="Publisher model" var="pubsub#publish_model">
<option>
<value>publishers</value>
</option>
<option>
<value>subscribers</value>
</option>
<option>
<value>open</value>
</option>
<value>open</value>
</field>
<field type="list-multi" label="Roster groups allowed to subscribe" var="pubsub#roster_groups_allowed"/>
<field type="jid-multi" label="People to contact with questions" var="pubsub#contact"/>
<field type="text-single" label="Default language" var="pubsub#language">
<value>English</value>
</field>
<field type="jid-multi" label="Node owners" var="pubsub#owner">
<value>mypublisher@example.com</value>
</field>
<field type="jid-multi" label="Node publishers" var="pubsub#publisher"/>
<field type="list-single" label="Select entity that should receive replies to items" var="pubsub#itemreply">
<value>owner</value>
</field>
<field type="jid-multi" label="Multi-user chat room to which replies should be sent" var="pubsub#replyroom"/>
<field type="jid-multi" label="Users to which replies should be sent" var="pubsub#replyto"/>
<field type="boolean" label="Send items to new subscribers" var="pubsub#send_item_subscribe">
<value>1</value>
</field>
<field type="boolean" label="Persist items to storage" var="pubsub#persist_items">
<value>1</value>
</field>
<field type="text-single" label="Max number of items to persist" var="pubsub#max_items">
<value>5</value>
</field>
<field type="text-single" label="Max payload size in bytes" var="pubsub#max_payload_size">
<value>5120</value>
</field>
</x>
</query>
</iq>
【问题讨论】:
【参考方案1】:是的,我知道了,当订阅者使用以下节上线时,他/她可以检索旧发布的项目
subid
在这种情况下是必须的
<iq type='get'
from='subscriber@example.com'
to='pubsub.example.com'
id='items1'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<items node='mynode'
subid="8839399494949"/>
</pubsub>
</iq>
【讨论】:
嗨,您是否尝试过在 android 中使用 smack 获取已发送消息的传递报告。你能分享一些代码吗?我也在做和这个问题一样的事情.. 请参考这个问题***.com/questions/7241444/…@Hunt 您的问题是什么,您在获取旧邮件时遇到问题了吗? 否,我想知道邮件是否已送达。所以我问你。之后,我从消息事件侦听器中获得了解决方案。现在工作正常。感谢您回复@Hunt以上是关于获取发布者的离线消息的主要内容,如果未能解决你的问题,请参考以下文章