最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - XEP-0077 In-band registration with Strophe.js and openfire usage - Stack Overflow

programmeradmin4浏览0评论

I'm trying to register a new user on openfire server with the strophe plugin but it doesn't connect for the registration. The description here doesn't bring me any further :( Do I have to establish a connection before? This is what I try when clicking a button to 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);
});

I'm trying to register a new user on openfire server with the strophe plugin but it doesn't connect for the registration. The description here https://github./metajack/strophejs-plugins/tree/master/register doesn't bring me any further :( Do I have to establish a connection before? This is what I try when clicking a button to 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);
});
Share Improve this question edited May 2, 2012 at 14:59 user1054134 asked May 2, 2012 at 12:58 user1054134user1054134 4631 gold badge4 silver badges21 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

On this line:

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

connection should be a Strophe.Connection object already created with your service URL ("http://localhost:7070/http-bind/").

The first parameter to connection.register.connect() is the host that you want to register an account on. That is, for a JID of [email protected] you would set it to "example.", not "http://localhost:7070/http-bind/" as in your code.

in my case I modified the plugin, because in line 215 "if(register.length === 0)", always end my intent for register, so I mented these lines and removed a tag "x" than brings in my stanza and the register was posible. I hope this help you.

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

评论列表(0)

  1. 暂无评论