こんにちは、iframe で標準の comet co を使用していますが、ページを離れてもメソッドはサーバー上で実行され続けます。接続がいつ閉じられたかを検出する必要があります。サイクルは永続的でなければなりませんが (true)、定期的に終了することはできません。誰かが私を助けることができます、ありがとう
バックエンド;
set_time_limit(0);
//Turn of Apache output compression
// Necessary if you have gzip setup in your httpd.conf (e.g. LoadModule deflate_module modules/mod_deflate.so)
apache_setenv('no-gzip', 1);
ini_set('zlib.output_compression', 0);
//Disable all PHP output buffering
ini_set('output_buffering', 'Off');
ini_set('implicit_flush', 1);
ob_implicit_flush(1);
for ($i = 0, $level = ob_get_level(); $i < $level; $i++) {
ob_end_flush();
} //Flush all levels of the buffer to start
error_reporting(E_ALL);
while( true ){
$a = getAct();
if($a)
echo $a;
$randSleep = mt_rand(400000, 600000);
usleep($randSleep);
}