Hi
We are upgrading to the new Smack library 4.0.2 (previously 3.4.1) and we have noticed in our application that we no longer have presence registered on start up. Presence updates work - but the inital load up does not work.
All the information is transfer on the login command. I did some digging.
v3.4.1 -> XMPPConnection -> login
The roster is loaded first from the server - once done the presence is sent out (and subsequently presence is sent back) - all good.
if(roster == null)
roster = new Roster(this);
if(config.isRosterLoadedAtLogin())
roster.reload();
if(config.isSendPresence())
packetWriter.sendPacket(new Presence(org.jivesoftware.smack.packet.Presence.Type.available));
v4.0.2 -> XMPPTCPConnection -> login
The presence is sent first. Then later in the same method a call to this method executes the RosterReload () from a connectionListener added in the Roster Class method Roster.
// Set presence to online.
sendPacket(new Presence(Presence.Type.available));
.
.
.
callConnectionAuthenticatedListener();
The reason this is a problem is because in class Roster the PresencePacketListener checks the Presence update to ensure the users JID is loaded in the Roster. If it is not loaded (in this case because the Presence is received before the Roster) - then then listeners are not fired.
// If the user is in the roster, fire an event.
RosterEntry entry = entries.get(key);
if (entry != null) {
fireRosterPresenceEvent(presence);
}
Is this intentional? Should we be doing something different to ensure we read presence and not rely on this?
Sorry if this is obvious - it is my first post
Thanks
Matt