首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >XMPP - Strophe.register.js

XMPP - Strophe.register.js
EN

Stack Overflow用户
提问于 2014-04-29 15:33:08
回答 1查看 1.6K关注 0票数 0

我正在尝试向我的XMPP服务器添加新用户。我正在使用strophe.register.js,这是我的代码

代码语言:javascript
复制
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!");
        // calling login will authenticate the registered JID.
        connection.register.authenticate();
      } else if (status === Strophe.Status.CONFLICT) {
        console.log("Contact already existed!");
      } else if (status === Strophe.Status.NOTACCEPTABLE) {
        console.log("Registration form not properly filled out.")
      } else if (status === Strophe.Status.REGIFAIL) {
        console.log("The Server does not support In-Band Registration")
      } else if (status === Strophe.Status.CONNECTED) {
        console.log('logged in')
      } else {
        console.log("every other status a connection.connect would receive");
      }
    };


    $("#registerBtn").click(function(){
      connection.register.connect("192.168.1.77/bosh/", callback, 60, 1);

    })

当我单击#registerBtn时,我希望用uname: juliet和pass: R0m30创建用户。

相反,我在控制台中得到了错误: TypeError: that._buildBody不是来自strophe.register.js第106行的函数

我检查了几乎所有的xmpp连接的问题,我无法找到解决办法。

我尝试过这个解决方案:Register XMPP-Account using the Strophe.js-Register-Pluging,但它对我不起作用。有人知道吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-06-26 03:47:27

我也有同样的问题。我用https://github.com/strophe/strophejs-plugins/tree/master/register修复了它。此外,确保connection.register.connect("192.168.1.77/bosh/",回调( 60,1)中的"192.168.1.77/bosh/“被您在XMPP服务器注册的主机的名称替换,比如ejabberd。例如“example.com”或“localhost”等等。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23369063

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档