Hey there,
I am trying to get PubSub to work. I am publishing an item to the node with payload like this:
SimplePayload payload = new SimplePayload("book","pubsub:location", "<test xmlns='pubsub:test'><time>" + System.currentTimeMillis() + "</time></test>"); PayloadItem payload = new PayloadItem("test" + System.currentTimeMillis(), payload);
node.send(payload);
This works fine. I can also see the payload in the mySQL database.
However I am not able to receive the payload. I am trying to receive the payload like this:
class ItemEventCoordinator implements ItemEventListener<PayloadItem>
{
public static final String TAG = "ItemEvent"; @Override
public void handlePublishedItems(ItemPublishEvent items)
{
Log.v(TAG,"Got something from " + items.getNodeId());
Log.v(TAG,"Item count: " + items.getItems().size()); Object itm = items.getItems().get(0);
PayloadItem<Item> item = (PayloadItem<Item>) itm;
}
}
I always get this exception after the logs:
Exception in packet listener
java.lang.ClassCastException: org.jivesoftware.smackx.pubsub.Item cannot be cast to org.jivesoftware.smackx.pubsub.PayloadItem
What is the right way to get the payload from a PubSub node?
I got the info from here https://www.igniterealtime.org/builds/smack/docs/latest/documentation/extensions /pubsub.html and I set deliverPayload to true.
Thank you in advance