如何使用 Smack 在 PubSub 节点上设置发布者?
How can I set the publisher on a PubSub node using Smack?
我正在开发与 Smack 库和 Openfire 服务器的聊天。我想在我的 pubsub 节点上将用户设置为发布者。
我在网上搜索过,但找不到任何内容。
我已经使用以下配置设置了 pubsub:
nodeconfig.setPublishModel(PublishModel.publishers);
我看到我可以创建从属关系:
Affiliation af = new Affiliation(mypubsub,Affiliation.Type.publisher);
我能做什么?
您需要通过 Node.getNodeConfiguration()
检索节点的 ConfigurationForm
,使用 createAnswerForm
从中创建一个答案表单,然后调用 Form.setAnswer(String, String)
设置 pubsub#publisher
选项。然后发送带有 Node.sendConfigurationForm(Form)
.
的答案表
from.setAnswer("pubsub#publisher", "publisher@example.org");
另见 XEP-60 8.2。
我正在开发与 Smack 库和 Openfire 服务器的聊天。我想在我的 pubsub 节点上将用户设置为发布者。 我在网上搜索过,但找不到任何内容。
我已经使用以下配置设置了 pubsub:
nodeconfig.setPublishModel(PublishModel.publishers);
我看到我可以创建从属关系:
Affiliation af = new Affiliation(mypubsub,Affiliation.Type.publisher);
我能做什么?
您需要通过 Node.getNodeConfiguration()
检索节点的 ConfigurationForm
,使用 createAnswerForm
从中创建一个答案表单,然后调用 Form.setAnswer(String, String)
设置 pubsub#publisher
选项。然后发送带有 Node.sendConfigurationForm(Form)
.
from.setAnswer("pubsub#publisher", "publisher@example.org");
另见 XEP-60 8.2。