views:

140

answers:

1

Smack's XMPPConnection implements an event-driven manner of receiving XMPP responses from a jabber server. The method [addPacketListener][1] 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 ? Thanks.

[1]: http://www.igniterealtime.org/builds/smack/docs/latest/javadoc/org/jivesoftware/smack/XMPPConnection.html#addPacketListener(org.jivesoftware.smack.PacketListener, org.jivesoftware.smack.filter.PacketFilter)

A: 

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

Jacques René Mesrine