powered by Jive Software

Patch: Register RosterListener Before Login


here is a patch that allows the registration of RosterListeners to the Roster before logging into the XMPP server.

Connection#getRoster() will now return an instance of the Roster instead of null if the user is not logged.
If not logged in all modifying methods of the Roster will throw an IllegalStateException analogue to the behavior of Connection#addConnectionListener().

This patch avoids missing some Roster events if the RosterListener is registered after login. Some changes to presences and the Roster are stored on the XMPP server while being offline. If Smack logs in all incoming Packets are processed correctly but it could happen that the RosterListener wasn’t registered at that time.

There are some test cases included which verify that the Roster works the same as before although it is initialized while being offline.

The patch fixes SMACK-156.

Best regards
register_rosterlistener_before_login.patch.zip (5246 Bytes)