使用Smack从XMPP PubSub节点检索最后一个项目总是只返回一个项目



我正在为我的Android应用程序使用最新的Smack(4.1)。

从节点检索持久项时,它是否只为每个用户返回最新发布的项?现在,当我尝试调用getItems时,我似乎只从每个用户那里获得最新发布的事件。我想从节点中检索所有项,即使每个用户有多个项。

这是我目前用于检索的代码:

PubSubManager manager = new PubSubManager(connectionManager.getConnection());  
node = manager.getNode(nodeList);  
Collection<PayloadItem<EventItem>> eventItems = node.getItems(25);  
Log.e(TAG, "Collection size: " + eventItems.size());  
List<PayloadItem<EventItem>> payloadList = new ArrayList<>();  
for(PayloadItem<EventItem> payload : eventItems) {  
eventItemList.add(payload.getPayload());  
}

这是我的节点配置表单:

ConfigureForm configureForm = new ConfigureForm(DataForm.Type.submit);  
configureForm.setAccessModel(AccessModel.open);  
configureForm.setDeliverPayloads(true);  
configureForm.setNotifyRetract(true);  
configureForm.setPersistentItems(true);  
configureForm.setPublishModel(PublishModel.open);  

正如您所知,setPersistentItems是真的。如果一个用户向一个节点提交两个项目,然后调用getItems,则只接收到其发布的项目中的最新项目。调试显示我只收到以下内容:

<?xml version="1.0" encoding="UTF-8"?>  
<iq to="pubsub.example.com" id="4cw4Z-27" type="get">  
<pubsub xmlns="http://jabber.org/protocol/pubsub">  
<items node="TESTNODE" max_items="25" />  
</pubsub>  
</iq>  

<?xml version="1.0" encoding="UTF-8"?>  
<iq from="pubsub.example.com" to="afa@example.com/Smack" id="4cw4Z-27" type="result">  
<pubsub xmlns="http://jabber.org/protocol/pubsub">  
<items node="TESTNODE">  
<item id="bool@example.com/Smack">  
<newevent xmlns="http://jabber.org/protocol/newevent" xml:lang="en">  
<sender>bool@example.com</sender>  
<title>Test Title 2</title>  
<description>Test description</description>  
</newevent>  
</item>  
</items>  
</pubsub>  
</iq>  

这是我在调试中唯一收到的东西。除了该特定用户和其他用户的最新发布项目外,不存在其他项目。

很明显,我正在接收存储在节点中的项目,但是服务器只为每个用户返回最新发布的项目。我想检索发布到节点的所有项目,不管它是否是该用户的最新项目。

这是服务器设置问题吗?我很感激任何建议。谢谢

这可能是服务器限制。XEP-60 6.5.7使max_items成为可选功能。

我将有效负载项的JID设置为用户的JID。结果,我覆盖了以前的ID,用户以前提交的内容也被覆盖了。我将PayLoadItem的ItemID设置为null,这样服务器每次都会生成一个唯一的ID,这样之前的项目就不会被覆盖。

最新更新