使用Strophe.js和Openfire进行带内注册的XEP-0077用法

4
我正在尝试使用strophe插件在openfire服务器上注册新用户,但无法连接进行注册。这里的描述https://github.com/metajack/strophejs-plugins/tree/master/register没有帮助我更进一步 :( 我需要在注册之前建立连接吗?这是我点击注册按钮时尝试的内容:
$("#RegButton").click(function () {
var callback = function (status) {
if (status === Strophe.Status.REGISTER) {
    connection.register.fields.username = "juliet";
    connection.register.fields.password = "R0m30";
    connection.register.submit();
} else if (status === Strophe.Status.REGISTERED) {
    console.log("registered!");
    connection.authenticate();
} else if (status === Strophe.Status.CONNECTED) {
    console.log("logged in!");
} else {
    // every other status a connection.connect would receive
}
};
connection.register.connect("http://localhost:7070/http-bind/", callback);
});
2个回答

4

在这一行:

connection.register.connect("http://localhost:7070/http-bind/", callback);

connection 应该是一个已经使用你的服务 URL ("http://localhost:7070/http-bind/") 创建的Strophe.Connection 对象。

connection.register.connect() 的第一个参数是你想要在哪个主机上注册账户。也就是说,对于 JID user@example.com,你应该将它设置为 "example.com",而不是你代码中的 "http://localhost:7070/http-bind/"


4

在我的情况下,我修改了插件,因为在第215行 "if(register.length === 0)",总是使我的注册意图结束,所以我评论了这些行并删除了标签"x",将我的stanza带入后,注册就变得可行了。我希望这可以帮助你。

    /*
      if (register.length === 0) {
        console.log('En tra if de linea 220');
        //that._changeConnectStatus(Strophe.Status.REGIFAIL, null);
        //return;
    } else */
    this.enabled = true;

我也遇到了strophe.register.js的同样问题,通过注释掉相同的行来解决。我正在使用prosody作为XMPP服务器。你在使用什么服务器? - Ando

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接