Hi,
I’m writing a pub sub subscription client and have chosen su smack as a helper library.
There is very little sample code and apparently no guide or manual, so I have done my best with the following, which unfortunately does not work (listener never gets called, though I see valid pubsub events in the received message debug stream). I have been able to subscribe to the topic, etc; it is only event reception that is the problem.
Has anyone got this working? Or should I be using a different approach?
PacketFilter packetFilter = XMPPUtils.createPubSubFilter();
PacketListener packetListener = XMPPUtils.createEventPacketListener(
new PubSubEventListener() {
public void onDelete(DeleteElement deletedElt)
throws Exception {
System.out.println("*** d ***");
} public void onPublish(ItemElement publishedElt)
throws Exception {
System.out.println("*** item ***");
System.out.println(publishedElt.getContentXML());
} public void onPurge(PurgeElement purgedElt)
throws Exception {
System.out.println("*** p ***");
} public void onRetract(RetractElement retractedElt)
throws Exception {
System.out.println("*** r ***");
}
}
); c.addPacketListener(packetListener, packetFilter);