How to send / receive customize item payload on pubsub node

被刻印的时光 ゝ 提交于 2019-12-10 14:58:47

问题


How to send / receive customize item on pubsub node with payload, I am using qsmack lib.

here is my code.

StringBuilder strBuffer = new StringBuilder();  
strBuffer.append("<x xmlns=");
strBuffer.append("jabber:x:data");
strBuffer.append(">Test</x>");      
String xml = strBuffer.toString();

SimplePayload item = new SimplePayload("test1111","pubsub_test_book", xml);

// Publish an Item with payload

leafNode.send(new PayloadItem<SimplePayload>("test123", item));

when I am trying to send payload item on node, I got an error message from server no response from server and connection disconnected.


回答1:


After long try , I found answer how to send and receive payload on pub sub node. While creating pubsub node I am using ConfigureForm, that will create a problem in my case. So I am creating node without configuration form.

mLeafNode = (LeafNode) mPubSubManager.createNode(nodeId);

It will solved my problem. Now I can send and receive payload item.

SimplePayload item = new SimplePayload("test1111","pubsub_test_book", xml_string);

leafNode.send(new PayloadItem("test123", item));



来源:https://stackoverflow.com/questions/20190546/how-to-send-receive-customize-item-payload-on-pubsub-node

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!