Not logged in. · Lost password · Register
Forum: MatriX and XmppDotNet RSS
Avatar
JoeBobMcStinky #1
User title: Bridge Troll
Member since Aug 2011 · 3 posts
Group memberships: Members
Show profile · Link to this post
Subject: Matrix.Xmpp.Roster.Roster trouble
void rc_OnRosterItem(object sender, Matrix.Xmpp.Roster.RosterEventArgs e)
        {
            if (e.RosterItem != null)
                r.AddRosterItem(e.RosterItem);
        }
Works fine, I can add roster items to it no problem and read the whole roster as a string with r.ToString(). It's definitely loading

foreach (Matrix.Xmpp.Roster.RosterItem ri in r.GetRoster())

Doesn't complain for lack of a GetEnumerator, but doesn't seem to find any RosterItems to iterate

foreach (Matrix.Xmpp.Roster.RosterItem ri in r)

Complains that Matrix.Xmpp.Roster.Roster does not contain a public definition for GetEnumerator.

Have I missed something obvious?
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
When you login MatriX automatically requests the roster by default. Fir each roster item the OnRosterItem event is fired one. MatriX does not store the roster for you in a collection. So you can't enumerate over it.
The GerRoster method can be used only when you manual request the roster and want to enumerate over the result which I wouldn't suggest.

Alex
Avatar
JoeBobMcStinky #3
User title: Bridge Troll
Member since Aug 2011 · 3 posts
Group memberships: Members
Show profile · Link to this post
public Matrix.Xmpp.Roster.Roster r = new Matrix.Xmpp.Roster.Roster();

The call to r.AddRosterItem(e.RosterItem); was referencing this (I figured that was implied in the code I posted sorry). I have instanced my own roster, added items, and still can not enumerate them when OnRosterEnd fires.

From what you say this foreach (Matrix.Xmpp.Roster.RosterItem ri in r) is the method to use on my own roster instance but that doesn't work either
This post was edited on 2011-08-14, 22:38 by JoeBobMcStinky.
Avatar
Alex #4
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by JoeBobMcStinky:
public Matrix.Xmpp.Roster.Roster r = new Matrix.Xmpp.Roster.Roster();

Quote by JoeBobMcStinky:
this just creates the XML representation of a roster object.
The call to r.AddRosterItem(e.RosterItem); was referencing this (I figured that was implied in the code I posted sorry). I have instanced my own roster, added items, and still can not enumerate them when OnRosterEnd fires.

yes, this is correct. I think you have a problem with the basic understanding how the library works.
all you need it the OnRosterItem event. Take the item from there and put it to a HashTable, Dictionary or whatever you prefer for enumerating your contacts.

Alex
Avatar
JoeBobMcStinky #5
User title: Bridge Troll
Member since Aug 2011 · 3 posts
Group memberships: Members
Show profile · Link to this post
Pretty lame man. I suppose you have a reason for not including this method for that class. It seems silly that the Roster class can be instanced, and objects added to it, but it has no methods for update, remove, or even enumerate. It appears underdeveloped to me. This leads me to question what other underdeveloped obstacles I might hit with this library. This dramatically lessens the likelihood that I might purchase a license. I will keep playing with it before rendering a final decision but that didn't help your sales pitch.
This post was edited on 2011-08-14, 23:58 by JoeBobMcStinky.
Avatar
Alex #6
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
thanks for you compliments to our products ;-)

This code works for me without any problems:

  1. public void TestRoster()
  2. {
  3.     var r = new Matrix.Xmpp.Roster.Roster();
  4.     for (int i = 0; i < 10; i++)
  5.     {
  6.         r.AddRosterItem(new RosterItem
  7.                             {
  8.                                 Jid = "test" + i + "@server.com",
  9.                                 Name = "test" + i
  10.                             });
  11.     }
  12.    
  13.     foreach (RosterItem rosterItem in r.GetRoster())
  14.     {
  15.         Console.WriteLine(rosterItem);
  16.     }
  17. }
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: