I am new to Openfire and smack, therefore I have questions regarding pubsub feature. Actually, I have created a node with setAccessModel as authorize, and setPublishModel as subscribers in android, as shown below.
PubSubManager mgr = new PubSubManager(xmpp.getConnection());
try {
LeafNode leaf = mgr.createNode("testNode");
ConfigureForm form = new ConfigureForm(DataForm.Type.submit);
form.setAccessModel(AccessModel.authorize);
form.setDeliverPayloads(true);
form.setNotifyRetract(true);
form.setPersistentItems(true);
form.setPublishModel(PublishModel.subscribers);
leaf.sendConfigurationForm(form);
} catch (SmackException.NoResponseException e) {
e.printStackTrace();
} catch (XMPPException.XMPPErrorException e) {
e.printStackTrace();
} catch (SmackException.NotConnectedException e) {
e.printStackTrace();
}
My question is that when somebody wants to subscribe to above node using below code, how the owner of this node can handle the subscription request?
PubSubManager mgr = new PubSubManager(xmpp.getConnection()); // Get the node
LeafNode node = null;
try {
node = mgr.getNode("testNode");
node.addItemEventListener(new ItemEventCoordinator());
node.subscribe(senderUser+"@desi.loc");
} catch (SmackException.NoResponseException e) {
e.printStackTrace();
} catch (XMPPException.XMPPErrorException e) {
e.printStackTrace();
} catch (SmackException.NotConnectedException e) {
e.printStackTrace();
} class ItemEventCoordinator implements ItemEventListener {
@Override
public void handlePublishedItems(ItemPublishEvent items) {
final ItemPublishEvent itemstemp=items;
runOnUiThread(new Runnable() {
@Override
public void run() {
//stuff that updates ui
dspySub.setText("Item: " + itemstemp.getItems());
}
});
}
}
When I set form.setAccessModel(AccessModel.open) and form.setPublishModel(PublishModel.open) every thing works fine. Users can publish and subscribe easily but when AccessModel is authorize, owner don’t listen the subscription request. I am sure I don’t know how to handle subscription request listener at owner side with above piece of code. Kindly guide me.