dtng25909 2014-03-14 17:30
浏览 39

PHP XMPP预绑定

I have reading tutorials, mailing lists, and other resources to understand how pre-binding actually works. I have found a few pre-bind scripts with PHP, used it, successfully got the jid, rid, sid but session always gets lost on page refresh.

I do the prebind on log in, then set the rid, jid, sid into a session cookie.

After logging in the prebind was successful. I am able to send messages. But on page reload the connection gets lost.

I have understood that on every request the RID must increment I have already coded that the rid cookie adds 1 on every refresh. But I just wanted to ask, do I have to pre-bind on every refresh? or only on log in?

I have seen a few example scripts that binds every page reload. I cannot do a pre-bind on each page reload because I cannot remember the password, nor can I save the password somewhere in the cookie to remember (because that's a security issue).

So, how does pre-binding really work? I am using openfire as a xmpp server.

This is the code on my login

$xmppPrebind = new XmppPrebind('xxxx', $bosh_url, 'xxxx', false);
$xmppPrebind->connect($user->username, $password);
$xmppPrebind->auth();
$sessionInfo = $xmppPrebind->getSessionInfo(); // array containing sid, rid and jid
Session::put('bosh_url', $bosh_url);
Session::put('bosh_jid', $sessionInfo['jid']);
Session::put('bosh_sid', $sessionInfo['sid']);
Session::put('bosh_rid', $sessionInfo['rid']);

After authenticating the user successfully I also log him/her in to the openfire server.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog