powered by Jive Software

Roster.createEntry() shows wrong status

First of all, kudos on an excellent API – I’'ve worked with some other XMPP libraries, and Smack is by far the best.

I am, however, seeing some unexpected behavior (I’‘m using the latest version, Smack 1.4.1) when adding buddies to the Roster – here’'s the situation:

I’‘m writing a client app with Smack. I’'m testing my client app by using it to log into to my local jabber server as “User_A”.

Using a release-quality Jabber client (I’'ve used both Gaim and WinJab with the same results), I log into the same local jabber server as “User_B”.

Initially, User_A is not in User_B’'s roster and vice versa.

I have my client app call Roster.createEntry() to invite User_B to join User_A’'s Roster.

User_B does get an invitation from User_A, as expected.

When User_B accepts User_A’‘s invitation, my client app (the one I’‘m writing with Smack) shows that User_B has accepted, that User_B is now in User_A’'s roster, and that User_B is now ‘‘available’’.

All of that is as as expected.

The unexpected part is this: after User_B accepts, User_B’'s client (Gaim or WinJab) shows User_A as offline, and that the roster request is still pending.

But, User_A is still online, and my client shows User_B in the roster correctly.

So my question is: after I send Roster.createEntry(), do I have to do anything else, to act upon the other user’'s acceptance?

I’'ve discovered the problem: it was my misunderstanding of the protocol.

I thought adding a user to the roster automatically subscribed me to presence updates, but strictly speaking, these are separate events and need to be transacted separately.

In my first prototype client, I left the Roster subscription setting to the default (SUBSCRIPTION_ACCEPT_ALL).

In a later prototype, which I used in the test described above, I called Roster.setDefaultSubscriptionMode(Roster.SUBSCRIPTION_MANUAL) .

That explains the behavior I saw: in the tests of the first prototype, a new Roster entry also meant an automatic presence subscription, and so I thought that’'s how the protocol was.