From 52b43a252d24cf9741b97c779c4ea0434c9e0e1b Mon Sep 17 00:00:00 2001 From: yggverse Date: Thu, 25 Apr 2024 14:55:13 +0300 Subject: [PATCH] fix handler function response --- README.md | 5 ++++- src/Server.php | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f4df70a..24a79e5 100644 --- a/README.md +++ b/README.md @@ -73,12 +73,15 @@ $server->start( function ( string $request, string $connect - ) { + ): ?string + { printf( 'connection: %s request: %s', $connect, $request ); + + return null; // null|string response } ); ``` diff --git a/src/Server.php b/src/Server.php index f6f875b..a347b27 100644 --- a/src/Server.php +++ b/src/Server.php @@ -145,6 +145,14 @@ public function start( $request, $connect ); + + if ($response) + { + fwrite( + $incoming, + $response + ); + } } fclose(