Not logged in. · Lost password · Register
Forum: XMPP Protocol RSS
Avatar
11alex11 #1
Member since May 2010 · 10 posts
Group memberships: Members
Show profile · Link to this post
Subject: Cant get normal users name Instead I get negative Long number (via chat connect - Facebook)
I connect to facebook chat When I try to retrieve the list of online users I get their user names but in negative long number. Y is that? How can I get their normal names?

thanks :)
Avatar
Alex #2
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
The Facebook usernames are negative numbers. But the name is also submitted.

e.g.:
  1. <item subscription="both" name="Bob Brown" jid="-1111111@chat.facebook.com" />

Alex
Avatar
11alex11 #3
Member since May 2010 · 10 posts
Group memberships: Members
Show profile · Link to this post
How do I write it in C#?

**I forgot to mention that I do all this things in c# (.net)
Avatar
Alex #4
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
which of our libraries are you using?

Alex
Avatar
11alex11 #5
Member since May 2010 · 10 posts
Group memberships: Members
Show profile · Link to this post
I use this code
Avatar
Alex #6
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
You have to subscribe to the OnRosteritem event. Then use the follwing code to get the name.

  1. private void XmppCon_OnRosterItem(object sender, agsXMPP.protocol.iq.roster.RosterItem item)
  2. {
  3.     string name = item.Name;
  4. }
Avatar
11alex11 #7
Member since May 2010 · 10 posts
Group memberships: Members
Show profile · Link to this post
It works :) thanks.

Can I connect between the name and the negative number? or between the Roster item and the Presence?
In Presence I have more functions to much to chat (status and etc'...)
Avatar
Alex #8
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by 11alex11:
Can I connect between the name and the negative number? or between the Roster item and the Presence?

yes, the name is only a user friendly description. You can populate a collection in the OnRosterItem event with the mapping Jid <--> name and look up them later when you need. The Jid is a unique identifier in XMPP. You get the Presence in the OnPresence event by Jid.

Alex
Avatar
11alex11 #9
Member since May 2010 · 10 posts
Group memberships: Members
Show profile · Link to this post
thanks every thing works :)
Avatar
tal170 #10
Member since May 2010 · 1 post
Group memberships: Members
Show profile · Link to this post
11alex11

can you please post the code you used to match the jid to the name, im still having trouble figuring it out for some reason, thanks.
Avatar
11alex11 #11
Member since May 2010 · 10 posts
Group memberships: Members
Show profile · Link to this post
        private void xmpp_OnRosterItem(object sender, agsXMPP.protocol.iq.roster.RosterItem item)
        {
            string itemName = item.Name;
            string itemJid = item.Jid.User;

            if (item.Name != null)
            {
                itemName.Replace('u', '-');
               
                nameLink.Add(new Names {jid = itemJid, name = itemName});

                _waitU = false;
                Console.WriteLine(" Got user List ");
            }
        }

nameLink is a list
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: