当我使用stropher.js连接到XMPP服务器时,它将连接状态设置为1 =当前正在建立连接
此状态有什么问题。
代码如下连接。
它使我恢复连接状态。
$(document).ready(function () {
$('#login_dialog').dialog({
autoOpen: true,
draggable: false,
modal: true,
title: 'Connect to XMPP',
buttons: {
"Connect": function () {
$(document).trigger('connect', {
jid: $('#jid').val(),
password: $('#password').val()
});
$('#password').val('');
$(this).dialog('close');
}
}
});
});
$(document).bind('connect', function (ev, data) {
var conn = new Strophe.Connection("http://127.0.0.1:5280/http-bind");
//"http://bosh.metajack.im:5280/xmpp-httpbind");
conn.connect(data.jid, data.password, function (status) {
if (status === Strophe.Status.CONNECTED) {
$(document).trigger('connected');
} else if (status === Strophe.Status.DISCONNECTED) {
Hello.log("Status DISCONNECTED.");
$(document).trigger('disconnected');
}
});
Hello.connection = conn;
});
$(document).bind('connected', function () {
// inform the user
Hello.log("Connection established.");
Hello.connection.addHandler(Hello.handle_pong, null, "iq", null, "ping1");
var domain = Strophe.getDomainFromJid(Hello.connection.jid);
Hello.send_ping(domain);
});
$(document).bind('disconnected', function () {
Hello.log("Connection terminated.");
// remove dead connection object
Hello.connection = null;
});
我正在使用手机间隙。
由于
答案 0 :(得分:0)
Stroph.Connection
的代码错误。首先,验证将URL参数传递给Stroph.connnection("URL")
是否有效。
$(document).bind('connect', function (ev, data) {
var conn = new Strophe.Connection("http://example.com:7070/http-bind");
//"http://bosh.metajack.im:5280/xmpp-httpbind");