Stizzo
Stizzo

Reputation: 25

How can I set the publisher on a PubSub node using Smack?

i'm developing a chat with Smack libraries and Openfire server. I would like to set a user to publisher on my pubsub node. I've searched for the web but i can't find anything.

I've set the pubsub with this configuration:

nodeconfig.setPublishModel(PublishModel.publishers);

I've saw that i can create the affiliation:

Affiliation af = new Affiliation(mypubsub,Affiliation.Type.publisher);

What can i do?

Upvotes: 2

Views: 657

Answers (1)

Flow
Flow

Reputation: 24063

You need to retrieve the Node's ConfigurationForm via Node.getNodeConfiguration(), create an answer form from it with createAnswerForm, and call Form.setAnswer(String, String) to set the pubsub#publisher option. Then send the answer form with Node.sendConfigurationForm(Form).

from.setAnswer("pubsub#publisher", "[email protected]");

See also XEP-60 8.2.

Upvotes: 2

Related Questions