使用 Strophe.js-Register-Plugin 注册 XMPP-Account

Register XMPP-Account using the Strophe.js-Register-Plugin

本文关键字:XMPP-Account 注册 js-Register-Plugin Strophe 使用      更新时间:2023-09-26

我尝试使用strophe-register-plugin(https://github.com/metajack/strophejs-plugins/tree/master/register)注册一个xmpp帐户。它适用于示例"http://bosh.metajack.im:5280/xmpp-httpbind"中的连接管理器,但我无法使用 OpenFire 连接管理器注册帐户。(正常登录适用于两个连接管理器...

连接状态更改是 1 -> 10,仅此而已。 1 表示"连接",但我不知道 10 是什么意思......

var connection = new Strophe.Connection(
//          "http://bosh.metajack.im:5280/xmpp-httpbind");
        "http://localhost/http-bind");
var callback = function (status) {alert(status);
    if (status === Strophe.Status.REGISTER) {
        connection.register.fields.username = "fghdfhg";
        connection.register.fields.name = "dfgfdgfdg";
        connection.register.fields.password = "dfddfgfdg";
        connection.register.submit();
    } else if (status === Strophe.Status.REGISTERED) {
        console.log("registered!");
        connection.authenticate();
    } else if (status === Strophe.Status.CONNECTED) {
        $(document).trigger('connected');
    } else if (status === Strophe.Status.DISCONNECTED) {
        console.log("Disconnected from XMPP-Server");
    }
};
//    connection.connect(data.jid, data.password, callback);
connection.register.connect("xyz.com", callback, 60, 1);

这种情况有一个解决方法:https://stackoverflow.com/a/10437474 和错误问题:https://github.com/metajack/strophejs-plugins/issues/93

strophe.register 中.js转到第 215 行并按照以下代码进行更改。

 /*if (register.length === 0) {
            that._changeConnectStatus(Strophe.Status.REGIFAIL, null);
            return;
        } else */
this.enabled = true;

试试上面的一个。