无法从 XMPP 服务器获取名册列表

Unable to get roster list from XMPP server

我在 https://www.blah.im 上创建了两个帐户用于测试目的。我使用 agsXMPP 客户端库与服务器通信。连接已通过身份验证,成员已登录。但不显示花名册。

这是我的代码

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();

    }

是否必须完成任何订阅才能获得可用成员?

是的,您需要将所有联系人添加到您的联系人列表(又名花名册)中,并正确订阅他们才能让他们出现。

添加 OnRosterItem 事件以查看您的联系人及其订阅状态,