通过strophe.register.js注册无效

时间:2016-02-05 10:41:59

标签: ejabberd strophe

我正在

  

TypeError:that._buildBody不是函数错误。

我正在使用 https://github.com/strophe/strophejs-plugins/tree/master/register

<script type="text/javascript" src="/Static/js/strophe.min.js"></script>
<script type="text/javascript" src="/Static/js/strophe.register.js"></script>
<script type="text/javascript">
$(document).ready(function () {
    connection = new Strophe.Connection("ws://127.0.0.1:5280/websocket");
    var callback = function (status) {
        if (status === Strophe.Status.REGISTER) {
            // fill out the fields
            connection.register.fields.username = "abcd";
            connection.register.fields.password = "abcd";
            // calling submit will continue the registration process
            connection.register.submit();
        } else if (status === Strophe.Status.REGISTERED) {
            console.log("registered!");
            // calling login will authenticate the registered JID.
            connection.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) {
            // do something after successful authentication
        } else {
            // Do other stuff
        }
    };
    connection.register.connect("Vostro-3558-PC", callback, 60, 1);
});
</script>

1 个答案:

答案 0 :(得分:0)

我自己就是遇到过这个。在我看来,strophe.register.js不适用于websockets - _buildBody函数特定于BOSH协议。