c5_labsci/web/admin/datasse/index.php
2026-01-27 00:52:00 +08:00

25 lines
765 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace web\admin\datasse;
class index {
static function sse_demo($senddata, $sendevent) {
global $db;
$rsuser = verifyfast();
if (nopower($db, $rsuser['id'], 'p610r'))
return errjson('您未被授权操作');
//多参数建议用strparam
//SSE支持data、type、id。其中type为空或fix。id可选可作为另一种数据。
$param = get('param');
$senddata('param: ' . $param);
for ($i = 0; $i < 100; $i++) {
if ($i % 10 == 1)
$senddata('ssr: ' . $i . "\n\n", $i);
$sendevent($i);
usleep(50000);
}
//$senddata('log: ' . json_encode($row, JSON_UNESCAPED_UNICODE));
$sendevent('ok');
}
}