From 5fd004f7c02b31e4cdb3100f4e989aa8b1c5d83a Mon Sep 17 00:00:00 2001 From: Timm Friebe Date: Sat, 2 Dec 2023 11:41:19 +0100 Subject: [PATCH] Implement `yield "delay" => $milliseconds` See https://github.com/xp-framework/networking/blob/4ad0c6ca01598b1f38437dffcdf9fc64a1ffd1af/src/main/php/peer/server/AsyncServer.class.php#L185 --- src/main/php/xp/web/WebRunner.class.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/php/xp/web/WebRunner.class.php b/src/main/php/xp/web/WebRunner.class.php index 66901123..12049ad8 100755 --- a/src/main/php/xp/web/WebRunner.class.php +++ b/src/main/php/xp/web/WebRunner.class.php @@ -1,5 +1,6 @@ application(); - foreach ($application->service($request, $response) ?? [] as $_) { } + foreach ($application->service($request, $response) ?? [] as $event => $arg) { + if ('delay' === $event) usleep($arg * 1000); + } $env->logging()->log($request, $response); } catch (Error $e) { self::error($request, $response, $env, $e); - } catch (\Throwable $e) { // PHP7 - self::error($request, $response, $env, new InternalServerError($e)); - } catch (\Exception $e) { // PHP5 + } catch (Throwable $e) { self::error($request, $response, $env, new InternalServerError($e)); } finally { $response->end();