1

如何在 c# .net 中使用 agsXMPP 库创建 Jabber 帐户?

我曾尝试在两个 Jabber 用户之间聊天,但对于他们两个,JID 已经在 J​​abber 网站注册时创建。

但是,我想在 C# 应用程序中使用 agsXMPP 库创建 JID 注册。

这可能吗?

4

1 回答 1

1

在连接之前,您必须将RegisterAccount属性设置为 true。图书馆尝试注册新帐户并在成功后使用此帐户登录(如果成功)。

成功创建帐户时引发OnRegistered事件。
OnRegisterError事件在错误时被调用。

XmppClientConnection xmpp = new XmppClientConnection();
// other code
xmpp.Username = "userName";
xmpp.Password = "secretPassword";
xmpp.RegisterAccount = true;

xmpp.OnRegisterError += xmpp_OnRegisterError;
xmpp.OnRegistered += xmpp_OnRegistered;
xmpp.Open();

void xmpp_OnRegistered(object sender)
{
    //handle accordingly
}


void xmpp_OnRegisterError(object sender, agsXMPP.Xml.Dom.Element e)
{
    //handle accordingly
}
于 2017-12-20T14:23:11.253 回答