我正在尝试实现 XMPP 客户端。我正在使用 BOSH 连接管理器,可以运行 Strophe.connect 但不能运行 Strophe.Attach。我试过增加 RID,但没有效果..有什么帮助吗?这里没有错误,但从未通过附加方法到达 Strophe.Status.CONNECTED,因此我无法发送 IQ 或 Presence。
这是我的代码尝试{
var cookieJid = $.cookie("jid");
var cookieSid = $.cookie("sid");
var cookieRid = $.cookie("rid");
var connt = new Strophe.Connection("http://localhost:7070/http-bind/");
connt.attach(cookieJid, cookieSid, cookieRid + 1, function(status)
{
if (status === Strophe.Status.CONNECTED)
{
alert ("hola connected");
$("#userName").append("hola connected : " + connt.jid );
var iq = $iq({type: 'get'}).c('query', {xmlns: 'jabber:iq:roster'});
connt.sendIQ(iq, handleRoster);
connt.send($pres());
}
});
}
catch (e)
{
$("#userName").append("Pinky error is " + e);
}
编辑
谢谢埃里克和查理。
所以我采用了最新的 Strophe.js,现在 Attached 状态确实有效。但是连接会立即断开。我什至无法获取名册。
我们可以像使用 connection.connect() 一样使用 Connection.attach() 做所有事情,对吧?
有什么想法吗?