Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
miramex #1
Member since Feb 2010 · 12 posts
Group memberships: Members
Show profile · Link to this post
Subject: Getting an object from OnRosterItem event
hi,
I m trying to get roster list and after studyin the sample and readin different subjects in the forum I didn t get where in the OnRosterItem event I can get an object that I will use to put contacts names on a list box for example !
in the sample its a whole RosterControl class that does everything but I just need for example the contacts names or jids !
Avatar
Alex #2
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
subscribe to the OnRosterItem handler. Here is an example:

  1. private void XmppCon_OnRosterItem(object sender, agsXMPP.protocol.iq.roster.RosterItem item)
  2. {
  3.     Console.WriteLine(item.Jid);
  4.     Console.WriteLine(item.Name);
  5. }

Alex
Avatar
miramex #3
Member since Feb 2010 · 12 posts
Group memberships: Members
Show profile · Link to this post
thank you alex that really made a lot of things clear for me ! but now I m wondering how can I get the presence at the same time of a contact that I m receiving in the XmppCon_OnRosterItem
here is what I made :

private void XmppCon_OnRosterItem(object sender, agsXMPP.protocol.iq.roster.RosterItem item)
  
      {
          listBox1.Items.Add(item.Jid+" "+"("+"XX"+")");
  
      }
       
I need something in XX to give the presence of the contact added to the listbox

then it will become something like this

private void XmppCon_OnRosterItem(object sender, agsXMPP.protocol.iq.roster.RosterItem item)
  
      {
          if (xx.Jid==item.Jid)
          listBox1.Items.Add(item.Jid+" "+"("+"xx.Presence"+")");
      }

all the problem is where am I going to get the object xx, I m thinkin of the On_Presence but I cant modify it to make it return an object ! what should I do ?
Avatar
Alex #4
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
you get the Presence later in the OnPresence event. If you get no presence packet at all for this user then the user is offline. You can consider all contacts as offline in the OnRosterItem event.
Avatar
miramex #5
Member since Feb 2010 · 12 posts
Group memberships: Members
Show profile · Link to this post
then I dont try to get the presence of users in the OnRosterItem but in the on presence ! then it goes something like this :

  1. private void XmppCon_OnPresence(object sender, Presence pres)
  2. {
  3.     if (InvokeRequired)
  4.     {
  5.         BeginInvoke(new OnPresenceDelegate(XmppCon_OnPresence), new object[] { sender, pres });
  6.         return;
  7.     }
  8.    
  9.     // here I m supposed to find the solution to select my users from the my listbox and update him to show his presence ?
  10.     // the users that I find in pres.From ?
  11. }
Avatar
Alex #6
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by miramex:
here I m supposed to find the solution to select my users from the my listbox and update him to show his presence ?
the users that I find in pres.From ?

yes, please also study our examples, there is everything you need.
Avatar
miramex #7
Member since Feb 2010 · 12 posts
Group memberships: Members
Show profile · Link to this post
Hi,
first of all, thank you so much alex for all your help, I really did well in my project and advancing really fast ! I m just missing some details and I hope you'll be able to help me as well as you did before !

I m trying to send my presence for other users ! I think that I can choose what presence I want to show (personnalize it) in other words I want to choose the titles of presence that a user can choose to show not only the ones provided by the showtype class !

meaning by all this to something like this :  XmppClientConnection.SendMyPresence ("Anything I want to wright here");
Avatar
Alex #8
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I think what you are looking for is the optional status message in XMPP.

  1. xmppCon.Status = "Anything I want to write here";
  2. xmppCon.SendMyPresence();

Alex
Avatar
miramex #9
Member since Feb 2010 · 12 posts
Group memberships: Members
Show profile · Link to this post
yes thats exactely what I was looking for ! thank you :)
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: agsXMPP RSS