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?
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.
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.
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.
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.
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: 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.