Question

Smack's XMPPConnection implements an event-driven manner of receiving XMPP responses from a jabber server. The method addPacketListener (org.jivesoftware.smack.PacketListener, org.jivesoftware.smack.filter.PacketFilter) allows you specify your own custom listener. I'm maintaining code in which one PacketListener handles all types of incoming messages. In the interest of improving the design, (with a nod to the Single Responsibility Principle), I plan to create separate listeners that handle specific types of packets. Is this a good idea ? Another issue is that the messages packet can come from many IM systems e.g. yahoo, google etc... ? Do I create a separate processors for each Yahoo, google services?

Was it helpful?

Solution

I've decided to use the multiple PacketListeners option. A single PacketListener would be doing too much work, with all the if-else-statements.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top