Not logged in. · Lost password · Register
Forum: MatriX RSS
Avatar
matianyi #1
Member since Mar 2012 · 19 posts · Location: Japan
Group memberships: Members
Show profile · Link to this post
Subject: How can i get the version of Roster
My Xmpp Server support Roster Version like this:
  1. <iq xmlns="jabber:client" to="user1@legendapl.com/36b083865d8c4a8880556f665a586eb6" type="result" id="MX_3">
  2.   <query xmlns="jabber:iq:roster" ver="2">
  3.     <item jid="user2@legendapl.com" name="User2" subscription="both">
  4.       <group>MyFriends</group>
  5.     </item>
  6.     <item jid="user3@legendapl.com" name="User3" subscription="both">
  7.       <group>MyFriends</group>
  8.     </item>
  9.   </query>
  10. </iq>

i can send the ver with XmppClient.RequestRoster() method, but i dont know how to get the version from the iq result.
This post was edited on 2012-03-26, 08:34 by Alex.
Edit reason: code formatting
Avatar
Alex #2
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
The roster version is in the OnRosterItem event in the EventArgs.

  1. private void xmppClient_OnRosterItem(object sender, Matrix.Xmpp.Roster.RosterEventArgs e)
  2. {
  3.     var version = e.Version;
  4. }

There is an RequestRoster() overload where you can pass the roster version.

  1. xmppClient.RequestRoster(14);

let me know if this helps. I am also open to API changes for this when they make it easier for you.

Normally you set AutoRoster to false and Request  the roster with the version you currently have at any time after login. When the roster changed then the server sends you the changes which you will get in the OnRosterItem event with the new version again.

Alex
Avatar
matianyi #3
Member since Mar 2012 · 19 posts · Location: Japan
Group memberships: Members
Show profile · Link to this post
Alex, thank you for your reply.

but, what i got is that the value of e.Version is always null.

i have another workaround method that works: request roster with iq then get roster version and item from the iq result.

  1. var iq = new RosterIq(IqType.get)
  2. {
  3.     Roster =
  4.     {
  5.         Version = m_version
  6.     }
  7. };
  8. m_xmppClient.IqFilter.SendIq(iq, XmppClientOnRoster);
  9.  
  10. private void XmppClientOnRoster(object sender, IqEventArgs e)
  11. {
  12.     var iq = e.Iq;
  13.     if (iq.Type == IqType.result)
  14.     {
  15.         var query = iq.Element<Roster>();
  16.         if (query != null)
  17.         {
  18.             foreach (var rosterItem in query.GetRoster())
  19.             {
  20.                 ...
  21.             }
  22.             m_version = query.Version;
  23.         }
  24.     }
  25. }
This post was edited on 2012-03-26, 08:34 by Alex.
Edit reason: code formatting
Avatar
Alex #4
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Have you done what I have suggested? Set AutoRoster to false and request the roster manual? MatriX should report the version.
If not then please post a Xml log here.

Alex
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