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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥15 cmd cl 0x000007b
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
    • ¥500 火焰左右视图、视差(基于双目相机)