سؤال

I'm working on an IM application on Android platform using asmack lib and openfire as xmpp server. Since user can't persist in chat room when disconnected from server, I decided to implement PubSubManager concept. And I gone through lot of links but couldn't get any good explanation for publishing with Payload and retrieving the message from the payload. Here is my code for creating and subscribing myself to that node and publishing a payload....

ConfigureForm form = new ConfigureForm(FormType.submit);
form.setAccessModel(AccessModel.open);
form.setDeliverPayloads(true);
form.setNotifyRetract(true);
form.setNotifyDelete(true);
form.setPublishModel(PublishModel.open);

leafNode = pubSubManager.createNode("testnode");
leafNode.sendConfigurationForm(form);

leafNode.subscribe(MY_JID);

SimplePayload payload = new SimplePayload(
            "elementname",
            "pubsub:testnode:elementname",
            "<elementname>my content</elementname>");
PayloadItem<SimplePayload> item = new PayloadItem<SimplePayload>(
             null, payload);

leafNode.publish(item);

I've no problem while publishing this item.When publishing this, my chat listener gets triggered (since I subscribed myself in that node) with a Message Object, from which I couldn't get message body (null). So whether my publishing process is correct , if so how can I retrieve it when receiving.?

هل كانت مفيدة؟

المحلول

You don't want to receive messages via the Chat, after all, it isn't actually a chat message.

See the pubsub documentation, specifically the section Receiving pubsub messages

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top