From 6e66984197e010d854823bfeeea9f9052f049e1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Thu, 4 Feb 2021 17:52:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HttpServer/Http/Request.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/HttpServer/Http/Request.php b/HttpServer/Http/Request.php index ac994f97..3d4683fb 100644 --- a/HttpServer/Http/Request.php +++ b/HttpServer/Http/Request.php @@ -77,6 +77,22 @@ class Request extends Application $this->fd = $fd; } + + /** + * @return array|null + * @throws ComponentException + */ + public function getConnectInfo(): array|null + { + if (empty($this->fd)) { + return null; + } + $server = Snowflake::app()->getSwoole(); + + return $server->connection_info($this->fd); + } + + /** * @return bool */