necromant2005 / tt-long-pooling
基于React的长连接池
1.0
2014-12-14 12:00 UTC
Requires
- php: >=5.4.0
- ext-libevent: *
- react/react: 0.4.*
This package is not auto-updated.
Last update: 2024-09-24 15:53:40 UTC
README
简介
PHP长连接
安装
主要设置
使用composer
- 将以下内容添加到您的composer.json文件中
"require": { "necromant2005/tt-long-pooling": "1.*", }
使用方法
use TweeLongPooling\Service\LongPooling; $options = [ 'callsLimit' => $callsLimit, 'callback' => $callback, 'response' => [ 'done' => $done, 'wait' => $wait, 'error' => $error, ], ]; (new LongPooling($options, $listen, $timePeriod))->run();
- $callsLimit - 系统迭代次数
- $callback - 每次迭代调用的函数
- $done - 完成时的响应
- $wait - 等待时的响应
- $error - 错误时的响应
- $listen - 监听端口数组
- $timePeriod - 迭代时间周期
回调函数将被调用$callsLimit次。如果$callback返回'true',则返回包含$done体的响应。如果$callback返回'false'且没有$callsLimit可执行,则返回包含$wait体的响应。如果回调函数既不返回'true'也不返回'false',则返回包含$error体的响应。