andrea11/xmpp-prebind-php

此类用于使用PHP预先绑定XMPP会话。

dev-master 2016-07-19 11:44 UTC

This package is not auto-updated.

Last update: 2024-09-23 06:26:55 UTC


README

此类用于预先绑定XMPP会话。

使用方法

  • 克隆仓库
  • 在你想进行预先绑定的文件中
/**
 * Comment here for explanation of the options.
 *
 * Create a new XMPP Object with the required params
 *
 * @param string $jabberHost Jabber Server Host
 * @param string $boshUri    Full URI to the http-bind
 * @param string $resource   Resource identifier
 * @param bool   $useSsl     Use SSL (not working yet, TODO)
 * @param bool   $debug      Enable debug
 */
$xmppPrebind = new XmppPrebind('your-jabber-host.tld', 'http://your-jabber-host/http-bind/', 'Your XMPP Clients resource name', false, false);
$xmppPrebind->connect($username, $password);
$xmppPrebind->auth();
$sessionInfo = $xmppPrebind->getSessionInfo(); // array containing sid, rid and jid
  • 如果你使用Candy,将Candy.Core.Connect()行修改为以下内容
Candy.Core.attach('<?php echo $sessionInfo['jid'] ?>', '<?php echo $sessionInfo['sid'] ?>', '<?php echo $sessionInfo['rid'] ?>');
  • 现在你应该使用PHP完成了预先绑定

调试

如果出现问题,你可以启用调试。调试输出将记录到FirePHP,因此你必须首先安装它。

其他语言

存在其他项目用于支持其他语言的预先绑定。去谷歌搜索吧 :)

请注意

此类功能并不完整。也可能存在错误。如果您愿意贡献或提交错误报告,我将非常感激。

谢谢。