Not logged in. · Lost password · Register
Forum: MatriX RSS
king_lee #1
Member since Jun 2013 · 1 post
Group memberships: Members
Show profile · Link to this post
Subject: A problem about add contact
I have the Matrix for .NET (version
In my application, I do user search, and then add a selected search item as contact, the add operation code like:

1. In the search form (User A) to submit the add contact request:
   var vjid = new Jid(lvUsers.SelectedItems[0].Text); 

2. In the main form (User B) to accept the request in xmppClient.OnPresence:
  1. if (e.Presence.Type == PresenceType.subscribe)
  2. {
  3.     var vfrmInfo = new frmMsgInfo("You have received a add contact request from ["
  4.                    + e.Presence.From + "], do you want to accept this?");
  5.     if (vfrmInfo.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  6.         presenceManager.ApproveSubscriptionRequest(e.Presence.From)//accept the request
  7.     else
  8.         presenceManager.DenySubscriptionRequest(e.Presence.From)//deny the request
  9. }

3. In the main form (User B) to add the contact (User A) to roster in presenceManager.OnSubscribe
  1. if (e.Presence.Type == PresenceType.subscribe)
  2. {
  3.    rosterManager.Add(e.Presence.From);
  4. }

Here, the add contact operation is completed, and the question is:
User B is in the User A's Online group, but User A is in the User B's offline group, and I try to relogin both, it remains so.
I tried the Mini Client of agsXMPP, and it has the same problem.

What can I do to make them in each the Online group both when they are both online?

This post was edited 2 times, last on 2013-07-06, 10:53 by Alex.
Alex #2
Member since Feb 2003 · 4296 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
you have no mutual subscription. On the side of user B you do only rosterManager.Add, but you don't ask for the presence. So you need to add also presenceManager.Subscribe on this side.

You can check the state of the subscription in the OnRosterItem event on login. The RosterItem must have a subscription of both on both sides.

In XMPP its required that both users send a subscription request an the request must be accepted on both sides.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: MatriX RSS