Binoy
Binoy

Reputation: 151

Unable to get roster list from XMPP server

I have created two accounts on https://www.blah.im for testing purposes. I use agsXMPP client library for communicating with server. The connection is authenticated right and member is logged in. But roster is not displayed.

This is my code

xmpp.Open(userName, password);
    xmpp.OnLogin += new ObjectHandler(xmpp_OnLogin);       
    Console.WriteLine(xmpp.XmppConnectionState);
    Console.WriteLine("Authenticated {0},", xmpp.Authenticated);   

  Console.WriteLine("Wait"); 
      int i = 0;  
      do {
       Console.Write(".");
       i++;
       if (i == 10)
           _wait = false;
       Thread.Sleep(3000);   
     } while (_wait);


Console.WriteLine("Connection state   {0}", xmpp.XmppConnectionState);
Console.WriteLine("Authenticated {0},", xmpp.Authenticated);

 agsXMPP.protocol.client.Presence p =
 new agsXMPP.protocol.client.Presence
(ShowType.chat, "Online");
 p.Type = PresenceType.available;
  xmpp.Send(p);
    xmpp.OnPresence += new agsXMPP.protocol.client.PresenceHandler(xmpp_OnPresence); 
     Thread.Sleep(3000);
     Console.WriteLine("Who do you want to connect ");
      string friend = Console.ReadLine();   
       Console.WriteLine("Start Chat");



static void xmpp_OnPresence(object sender, agsXMPP.protocol.client.Presence pres)
   {
          Console.WriteLine("Available Contacts: ");
          Console.WriteLine("{0}@{1}  {2}", pres.From.User, pres.From.Server, pres.Type);
          Console.WriteLine();

    }

Is there any subscription stuff that must be done to get the available members ?

Upvotes: 2

Views: 739

Answers (1)

Alex
Alex

Reputation: 4136

yes you need to add all the contacts to your contact list (aka roster), and be subscribed to them properly in order to get their presence.

Add the OnRosterItem event to see your contacts and their subscription status,

Upvotes: 1

Related Questions