this question is asked before here and here but i dont get answer from there. I'm developing application in which i'm using pubsub and xmpp, for android i'm using smack library. i want to send custom payload to the node and on receiving custom payload how to parse and display it in to list? now i am able to send and receive message but it is just a small example from documentaion. here is my example,
String msg = "room pubsub test";
SimplePayload payload = new SimplePayload("message", "pubsub:test:message", "<message xmlns='pubsub:test:message'><body>" + msg + "</body></message>");
PayloadItem<SimplePayload> item = new PayloadItem<>(null, payload);
node.publish(item);
and when i receive item
node.addItemEventListener(new ItemEventListener() {
@Override
public void handlePublishedItems(ItemPublishEvent items) {
System.out.println("======================handlePublishedItems==============================");
System.out.println(items.getItems());
}
}
and the output i'm getting is
[org.jivesoftware.smackx.pubsub.PayloadItem |
Content [<item id='5E277A9C33A58'>
<message xmlns='pubsub:test:message'>
<body xmlns='pubsub:test:message'>room pubsub test</body><
/message>
</item>]]
i want to send custom payload like the time at which message is sent, who have sent this message etc. so, how can i send custom payload? and how to parse it and show it to user?