Hi all,
I am new to smack pubsub.
I am using smackx to work with pubsub openfire.
Right now, there is serious issue in my code, I can’t get item back from node.
if i use
// retrieve nodes
private void retrieveNodes(Connection conn) {
// Create a pubsub manager using an existing Connection
PubSubManager mgr = new PubSubManager(conn); // Get the node
LeafNode node = null;
try {
node = (LeafNode) mgr.getNode("testNode");
node.subscribe(conn.getUser());
} catch (XMPPException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
node.addItemEventListener(new ItemEventCoordinator());
} class ItemEventCoordinator implements ItemEventListener {
@Override
public void handlePublishedItems(ItemPublishEvent items) {
System.out.println("Item count: " + items.getItems().size());
Collection<? extends Item> itemss = items.getItems();
for (Item item : itemss) {
PayloadItem pi = (PayloadItem) item; System.out.println("item: " + pi.toXML());
}
}
}
it only return the last one item with full payload.
if i use any methods like:
DiscoverItems nodeItems = node.discoverItems();
Iterator<org.jivesoftware.smackx.packet.DiscoverItems.Item> i =
nodeItems.getItems();
then, only return items without payload.
I try to use:
LeafNode node = (LeafNode) mgr.getNode("testNode");
List<? extends PayloadItem> items = node.getItems();
everytime, it returns
<iq type="error" id="Mj6e4-5" from="pubsub.stan-desktop" to="user1@stan-desktop/Smack"><pubsub xmlns="http://jabber.org/protocol/pubsub"><items node="testNode" max_items="100"/></pubsub><error code="400" type="modify"><bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/><subid-required xmlns="http://jabber.org/protocol/pubsub#errors"/></error></iq>
I searched the all fourm and internet wherever I can, but no answers works for me.
If anyone has some idea about how to retrieve all items with payload in the nodes, please help.
Regards
Stan