我已在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();
}
为了获得可用的成员,是否有必要进行的订阅?
答案 0 :(得分:1)
是的,您需要将所有联系人添加到您的联系人列表(也就是名册),并正确订阅它们以获得他们的存在。
添加OnRosterItem事件以查看您的联系人及其订阅状态