X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-webpanel.git/blobdiff_plain/563ebce73b1e5c5e41e0a6ba2868d5470d6530be..67bff06aa6fd4d7d3a9aefc2919307326fa6d755:/api/common_api.php diff --git a/api/common_api.php b/api/common_api.php index 36f2422..ccb1442 100644 --- a/api/common_api.php +++ b/api/common_api.php @@ -1,5 +1,5 @@ log()->subscribe($sources); if ($rpc->error) @@ -61,7 +89,10 @@ function api_log_loop($sources) * otherwise PHP may not * notice when the webclient is gone. */ - echo "\n"; + if ($fpm_workaround_needed) + echo str_repeat(" ", 4095)."\n"; + else + echo "\n"; continue; } send_sse($res); @@ -72,6 +103,11 @@ function api_timer_loop(int $every_msec, string $method, array|null $params = nu { GLOBAL $rpc; + /* First, execute it immediately */ + $res = $rpc->query($method, $params); + if (!$res) + die; + send_sse($res); $rpc->rpc()->add_timer("timer", $every_msec, $method, $params); if ($rpc->error) { @@ -87,6 +123,12 @@ function api_timer_loop(int $every_msec, string $method, array|null $params = nu } /* New style: use server-side timers */ + /* - First, execute it immediately */ + $res = $rpc->query($method, $params); + if (!$res) + die; + send_sse($res); + /* - Then add the timer */ for(;;) { $res = $rpc->eventloop(); @@ -96,7 +138,10 @@ function api_timer_loop(int $every_msec, string $method, array|null $params = nu * otherwise PHP may not * notice when the webclient is gone. */ - echo "\n"; + if ($fpm_workaround_needed) + echo str_repeat(" ", 4095)."\n"; + else + echo "\n"; continue; } send_sse($res);