ページの読み込み時にXMPP接続を作成できます。ただし、別のページに移動するたびに、同じ接続を使用してクライアントの定期的な通知を削除する必要があります。私は次のコードを使用しました。XMPP strophe接続接続プロセスに失敗しました
$(document).bind('connect', function (ev, data) {
var jid = $.jStorage.get('JID', null);
var sid = $.jStorage.get('SID', null);
var rid = $.jStorage.get('RID', null);
if ((jid != null) && (sid != null) && (rid != null)) {
var conn = new Strophe.Connection("http://localhost:5280/xmpp-httpbind");
conn.attach(jid, sid, rid, function() {
alert('Connection attach success.');
Gab.connection = conn;
});
}
else {
var conn = new Strophe.Connection("http://localhost: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) {
$(document).trigger('disconnected');
}
});
Gab.connection = conn;
}
});
そしてアンロードで:
$(window).unload(function() {
if (Gab.connection != null) {
Gab.connection.pause();
$.jStorage.set('JID', Gab.connection.jid);
$.jStorage.set('SID', Gab.connection.sid);
$.jStorage.set('RID', Gab.connection.rid);
} else {
$.jStorage.flush();
}
// Gab.connection = null;
alert('paused/disconnected');
})
それはFirebugのコンソールで(POST http://localhost:5280/xmpp-httpbindは404 36msが見つかりません)と言う、しかし、すぐにそれを添付して、接続に接続します。何か案は?
ありがとうございます。
どのサーバーが使用されましたか? – Zash
あなたは解決策を手に入れましたか? – Hunt