From a7f5d268de352cd37d2e20422abcb57a7488d055 Mon Sep 17 00:00:00 2001 From: netkas Date: Wed, 15 Jan 2025 13:55:33 -0500 Subject: [PATCH] Add support for handling PING requests in Socialbox --- src/Socialbox/Socialbox.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Socialbox/Socialbox.php b/src/Socialbox/Socialbox.php index 52ae74f..c903f0a 100644 --- a/src/Socialbox/Socialbox.php +++ b/src/Socialbox/Socialbox.php @@ -60,6 +60,10 @@ { switch($clientRequest->getRequestType()) { + case RequestType::PING: + self::handlePingRequest(); + break; + case RequestType::INFO: self::handleInformationRequest(); break; @@ -87,6 +91,18 @@ } + /** + * Handles an incoming ping request by sending a successful HTTP response. + * + * @return void + */ + private static function handlePingRequest(): void + { + http_response_code(200); + header('Content-Type: text/plain'); + print('OK'); + } + /** * Handles an information request by setting the appropriate HTTP response code, * content type headers, and printing the server information in JSON format.