所以,我正在建立我的第一个strophe聊天客户端。 我已经成功完成了一个发送和接收消息的简单客户端。现在我正在尝试在收到消息时打开一个新的浏览器窗口。新的浏览器窗口将附加到对话并继续它
但我不能为我的生活找到如何正确地做到这一点。
我认为这个过程是这样的:
1)获取并存储jid,rid和sid on connect
2)当我收到消息时,我通过jid,摆脱和sid到single.html
3)通过single.html我附加并尝试继续或开始对话
但我不知所措。它给我无效的SID并以此结束。 我真的不确定这是我正在瞄准的正确方法。
继承我对single.html的连接(sid,rid和jid成功传递,其中RID为+1,因为我读过是至关重要的)
var BOSH_JID = QueryString.boshjid;
var BOSH_SID = QueryString.boshsid;
var BOSH_RID = QueryString.boshrid+1;
function onConnect(status)
{
if (status == Strophe.Status.CONNECTING) {
console.log('Strophe is connecting.');
} else if (status == Strophe.Status.CONNFAIL) {
console.log('Strophe failed to connect.');
$('#connect').get(0).value = 'connect';
} else if (status == Strophe.Status.DISCONNECTING) {
console.log('Strophe is disconnecting.');
} else if (status == Strophe.Status.DISCONNECTED) {
console.log('Strophe is disconnected.');
$('#connect').get(0).value = 'connect';
} else if (status == Strophe.Status.CONNECTED) {
console.log("connected to session");
//log('Strophe is connected.');
connection.send($pres());
connection.addHandler(onMessage, null, "message", null, null, null);
//connection.disconnect();
}
}
$(document).ready(function () {
connection = new Strophe.Connection(BOSH_SERVICE);
connection.rawInput = rawInput;
connection.rawOutput = rawOutput;
//connection.connect(jid,password,onConnect);
connection.attach(BOSH_JID, BOSH_SID, BOSH_RID, onConnect);
//connection.disconnect();
});