如何在 pubsub 节点上发送/接收自定义项目负载 [英] How to send / receive customize item payload on pubsub node
问题描述
如何使用有效载荷在 pubsub 节点上发送/接收自定义项目,我使用的是 qsmack lib.
How to send / receive customize item on pubsub node with payload, I am using qsmack lib.
这是我的代码.
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.
推荐答案
经过长时间的尝试,我找到了如何在 pub 子节点上发送和接收有效负载的答案.在创建 pubsub 节点时,我正在使用 ConfigureForm,这会在我的情况下产生问题.所以我正在创建没有配置表单的节点.
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);
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);
SimplePayload item = new SimplePayload("test1111","pubsub_test_book", xml_string);
leafNode.send(new PayloadItem("test123", item));
leafNode.send(new PayloadItem("test123", item));
这篇关于如何在 pubsub 节点上发送/接收自定义项目负载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!