Re: how to create a mutual subscription(both)?

98 views
Skip to first unread message

Robbie Hanson

unread,
Feb 16, 2012, 8:31:26 PM2/16/12
to xmppfr...@googlegroups.com
> User A:
> XMPPPresence *presenceFromUserA = [XMPPPresence
> presenceWithType:@"subscribe" to:UserBJid];
> [[self xmppStream] sendElement:myPresenceSub];


Instead of this, you can simply use the [XMPPRoster addUser:withNickname:] method.

> //right next line, i do:
> XMPPPresence *presenceFromUserB = [XMPPPresence
> presenceWithType:@"subscribe" to:UserAJid];
> [[self xmppStream] sendElement:myPresenceSub];


This isn't needed. The previous call (with andAddToRoster:YES) handled all this for you.

> the result is:
> User A has two roster items: userB@localhost, userB@localhost/
> resource (this is wrong)


Yes, that's certainly wrong. The changes above might fix this problem. Although the bug still technically exists. What roster storage are you using?

-Robbie Hanson

On Feb 14, 2012, at 1:28 AM, skyline wrote:

> I would like to create a mutual subscription like this:
> userA sends a presence subscription to userB, then userB accepts the
> subscription request and subscribe back to userA.
>
> I tried the following:
>
> User A:
> XMPPPresence *presenceFromUserA = [XMPPPresence
> presenceWithType:@"subscribe" to:UserBJid];
> [[self xmppStream] sendElement:myPresenceSub];
>
> User B:
> [xmppRoster acceptPresenceSubscriptionRequestFrom:[presenceFromUserA
> from] andAddToRoster:YES withNickName:UserA];
> //right next line, i do:
> XMPPPresence *presenceFromUserB = [XMPPPresence
> presenceWithType:@"subscribe" to:UserAJid];
> [[self xmppStream] sendElement:myPresenceSub];
>
> the result is:
> User A has two roster items: userB@localhost, userB@localhost/
> resource (this is wrong)
> User B has one roster item: userA@localhost (this is correct)
>
> please correct me if i do anything wrong, or could you please suggest
> me a better solution?
> thanks
>
> --
> You received this message because you are subscribed to the Google Groups "XMPPFramework" group.
> To post to this group, send email to xmppfr...@googlegroups.com.
> To unsubscribe from this group, send email to xmppframewor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/xmppframework?hl=en.
>

skyline

unread,
Feb 17, 2012, 2:47:12 AM2/17/12
to XMPPFramework
sorry robbie, i thought i needed to read the XMPP documents for this
problem so i deleted my post, and i believe this is not a bug, it was
just something wrong i did in my code. After reading XMPP documents, i
found that same solution like you stated above "[XMPPRoster
addUser:withNickname:]". This fixed my problem.

thanks for your time.
Reply all
Reply to author
Forward
0 new messages