powered by Jive Software

Is this right? (Handling pubsub (smackx) payload items)

I’ve got a test project set up so that the below method will be called when we get a packet. It prints out exactly what I’d expect, but it seems awfully messy. The extension provider architecture is quite confusing to me right now, would appreciate any input. (ugh, need code formatting. I’ve got it here as well http://pastebin.com/dsfvUdMk )

private void handlePacket(Packet packet)

{

if (packet instanceof Message)

{

Message message = (Message)packet;

EventElement event = (EventElement) message.getExtension(“http://jabber.org/protocol/pubsub#event”);

if(event.getEvent() instanceof ItemsExtension) {

ItemsExtension itemExt = (ItemsExtension) event.getEvent();

List items = (List)itemExt.getItems();

for (PayloadItem item : items) {

System.out.println("got payload " + ((SimplePayload)item.getPayload()).toXML());

} } } }

Well, for pubsub specifically you can use the API provided to register a handler that is specific for your node. Then the code you have will become much cleaner.

Documented here

Hmm, interestingly that doesn’t work. When I run with debug=true I can see the items being received but they are never sent to my ItemEventListener.

Should I file a bug?

I would guess that you are missing something, as that is pretty basic to the functioning of the pubsub stuff and noone else has reported any errors in it. I know the test cases run fine so you may want to recheck your code, or you can post some here if you like and I can take a look.