powered by Jive Software

Roster Notifications

It seems that when a user adds another user to their roster, that user is not informed in any way. Is that right?

I’'d like for that user to be informed and have the opportunity to reciprocally add that user to their roster too.

Any advice much appreciated.

I’‘ve been thinking a bit more about this and I still haven’'t found a way to acheive what I want.

This is what I want to acheive.

UserX already exists and is signed on.

UserY doesn’‘t yet exist so they create a new account and sign in. Now, I want some way for UserY to inform UserX of their existence, perferably by adding themselves to userX’'s roster. Is this possible?

Well if it wasn’'t possible communicating to people using XMPP and Smack would be a fairly lonely experience

XMPP uses the concept of Presence. You have to request to see the Presence of another user.

You can do this easily via the Roster class within smack.

Something like

Roster roster = connection.getRoster();
roster.createEntry("nameofbuddy", "nickname", String[] groups);

What this will do is send a Subscription request to your buddy. They then have the option of accepting or declining the request. If they accept then you will be able to see their online Presence status. If they decline then you wont be able to see it.

hth

Jon

…yeah, that was what I was thinking too

I tried that, but the user who I added to my roster didn’‘t seem to receive any notification. However, it that is the right track I’'ll try again, perhaps there was something wrong with my test.

Thanks,

Alan

Well that would depend on which client you were testing it with.

If it was with your own then you would need to write the code to deal with the Subscription requests received.

My advice would be to download and install Jives Spark client as you can easily use it to view the XMPP packets being sent and received. Then turn on debugging in your own client so you can see exactly whats being sent and received and give it another go.

You should see a Presence Subscription request being sent from your client and Spark should then be notified.

Jon

Thanks Jon, got it working. What I was doing wrong was not specifying the full username of the form username@server in my roster.createEntry call, I missed out the @server bit.

Thanks Again.

Good to hear, I seem to remember making the same mistake when I 1st used the library

Just one more thing… If a userB adds userA to their roster and userA’'s subscriptions mode is SUBSCRIPTION_ACCEPT_ALL then this seems to mean that userB has userA in their roster and recieves presence information from userA, also userA has userB in their roster too but does NOT receive presence information from userB. This is what I am observing anyway.

If I want userA to receive userB’‘s presence information what do I do. In the roster info, I can see that the subscription=“from” and I’'m assuming it should be “both” but I am having a slight mental block as to how to get there.

User A:

User B:

User A: Requests presence subscription from User B

User B: Accepts subscription.

User A: Can now see User B’'s online presence.

User B though cannot see User A’'s presence because they havent requested it.

Now the default behaviour of most clients is if you accept a presence subscription to send a request back. The client who originally sent the request will automatically accept this as they have already requested subscription from the sending client.

The subscription type will then be “Both”.

Its quite a confusing topic tbh. Have a read of the RFC to clear up anything that still makes your head spin.

Jon

Thanks again Jon, got it working.