2014-01-16 39 views
0

我有Ejabberd服務器託管在遠程位置。我正在嘗試使用Strophe.js註冊插件註冊新帳戶,我找不到爲什麼這不起作用。下面是我寫的代碼Strophe.js註冊插件不工作

var connection = new Strophe.Connection("http://ip-address:5222/http-bind"); 
    var callback = function (status) { 
     alert(Strophe.Status.REGISTER); // Returning me 10 
     if (status === Strophe.Status.REGISTER) { 
      alert("Entered"); 
      connection.register.fields.username = "hello"; 
      connection.register.fields.password = "hello"; 
      connection.register.submit(); 
     } else if (status === Strophe.Status.REGISTERED) { 
      alert("registered!"); 
      connection.authenticate(); 
     } else if (status === Strophe.Status.CONNECTED) { 
      alert("logged in!"); 
     } else { 
      // Sometimes execution entering into this block. 
      document.body.innerHTML = (JSON.stringify(status)); 
     } 
    }; 
    connection.register.connect("localhost", callback); 

任何額外的代碼添加到此或我必須做的任何修復使這項工作。請幫助我。 Strophe.js文檔很糟糕。

+0

我對Strophe.js一無所知,但可以看到發送和接收的XMPP節嗎?看到這些人可能會立即發現問題。 – legoscia

+0

+1 - 啓用日誌記錄 –

+0

訣竅是同時使用RAW INPUT和RAW OUTPUT + CONNECTION STATUS來確定服務器的真實情況。請參閱此代碼:http://faraxmobile.com/r/afrika/hula3/js/models/connection/ConnectionModel.js 我必須警告您,我正在使用backbone.js和JOOP。 – 2014-01-17 18:58:56

回答

2

strophe.register.js轉到第215行,並根據下面的代碼進行更改。

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

嘗試以上之一。

2
var connection = new Strophe.Connection("http://ip-address:5222/http-bind/"); 

最後需要尾隨斜線。