added wss tools 8

This commit is contained in:
2026-06-18 20:00:25 +03:30
parent c15136c5e7
commit 21341c7f13
@@ -53,6 +53,9 @@ class PriceStreamController extends Controller
$lastId = $service->currentSeq();
$heartbeatTicks = 0;
echo "retry: 5000\n\n";
@flush();
while (! connection_aborted()) {
foreach ($service->consumeSince($lastId) as $event) {
$send((string) $event['event'], $event['data']);
@@ -60,9 +63,9 @@ class PriceStreamController extends Controller
}
$heartbeatTicks++;
if ($heartbeatTicks >= 30) {
echo ': ping '.time()."\n\n";
@flush();
// هر ۵ ثانیه — LiteSpeed/پروکسی اتصال بیکار را نمی‌بندد
if ($heartbeatTicks >= 10) {
$send('ping', ['ts' => time()]);
$heartbeatTicks = 0;
}