2

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?

Flow
  • 23,572
  • 15
  • 99
  • 156
Stizzo
  • 25
  • 5

1 Answers1

2

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", "publisher@example.org");

See also XEP-60 8.2.

Flow
  • 23,572
  • 15
  • 99
  • 156
  • What if i would like to remove the publisher? – Stizzo Jul 16 '15 at 14:42
  • The configuration form's `pubsub#publisher` field is of type `jid-multi` and contains not the delta, but the publisher list "to set" on the node. So if you want to remove a publisher you send the field with the list of publishers minus the publisher you want to remove. – Flow Jul 16 '15 at 14:59