Lost Presence packets

First of all, thanks for a GREAT open source library!

I’‘m running a demo setup with both a jabberd server and a client on the same machine and I noticed that the client often doesn’'t get the presence packets of its buddy when it logs in (in the case where the buddy was already logged in).

The presence packet IS received by the client (I used the -Dsmack.debugEnabled option to confirm this) however, the PresencePacketListener (inside the Roster class) never gets it.

The problem seems to be that the PresencePacketListener is created after the Presence packet arrives. I made a small modification to the XMPPConnection.login method - to only send the presence packet for the user AFTER the roster has been created (which requires reversing the order of the following calls:

// Set presence to online.

packetWriter.sendPacket(new Presence (Presence.Type.AVAILABLE));

// Finally, create the roster.

this.roster = new Roster(this);

roster.reload();

So instead I have:

// Finally, create the roster.

this.roster = new Roster(this);

roster.reload();

// Set presence to online.

packetWriter.sendPacket(new Presence(Presence.Type.AVAILABLE));

And then the client always gets the presence info.

I realize this is probably only an issue because I’‘m running the server and client on the same machine (since the client receives the presence info for it’‘s buddies before the Roster constructor has completed), but it’‘s a very easy fix and I don’'t think it breaks anything else.

Thanks,

Elisha

Seems reasonable to me. I’'ll file an issue in the bug tracker.

-iain