简体   繁体   English

从XMPP检索最后一项使用Smack的PubSub节点始终只返回一个项目

[英]Retrieving last items from XMPP PubSub Node with Smack always returns only a single item

I'm using the latest Smack (4.1) for my Android application. 我在我的Android应用程序中使用最新的Smack(4.1)。

When retrieving persistent items from a node, does it only return the latest published items for each user? 从节点检索持久性项目时,它是否仅为每个用户返回最新发布的项目? Right now, when I try to call getItems, I seem to only get the latest published event from each user. 现在,当我尝试调用getItems时,我似乎只从每个用户获取最新发布的事件。 I would like to retrieve all of the items from the node, even if there's more than one item for each user. 我想从节点中检索所有项目,即使每个用户有多个项目。

This is the code I'm using currently for retrieval: 这是我目前用于检索的代码:

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());  
}

This is my node configure form: 这是我的节点配置表单:

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

As you can tell, setPersistentItems is true. 如您所知,setPersistentItems为true。 If one user submits two items to a node and then calls getItems, only the latest of their published items is received. 如果一个用户向节点提交两个项目,然后调用getItems,则只接收最新的已发布项目。 The debug shows that I only receive the following: 调试显示我只收到以下内容:

<?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>  

This is the only thing I receive in the debug. 这是我在调试中唯一收到的东西。 No other items present except for the latest published one for that particular user and other users. 除了针对该特定用户和其他用户的最新发布项目之外,不存在其他项目。

It's clear that I am receiving the items stored in the node, however the server only returns the latest published item for each user. 很明显,我收到了存储在节点中的项目,但是服务器只返回每个用户的最新发布项目。 I would like to retrieve all items published to the node regardless if it's the latest one for that user or not. 我想检索发布到节点的所有项目,无论它是否是该用户的最新项目。

Is this a server setting issue? 这是服务器设置问题吗? I appreciate any advice or suggestions. 我感谢任何建议或意见。 Thanks! 谢谢!

This could possible be a server limitation. 这可能是服务器限制。 XEP-60 6.5.7 makes max_items a optional feature. XEP-60 6.5.7使max_items成为可选功能。

I was setting the JID of the payload item to the User's JID. 我正在将有效负载项的JID设置为用户的JID。 As a result, I was overwriting the previous ID's and the previous submissions from the user was being overwritten. 结果,我覆盖了以前的ID,并且用户之前的提交被覆盖了。 I set the PayLoadItem's ItemID to null and that let the server generate a unique ID each time, so the previous items would not be overwritten. 我将PayLoadItem的ItemID设置为null,这样服务器每次都会生成一个唯一的ID,因此不会覆盖之前的项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM