From ffdd692f9973c2f30a672e1869f213a698b93635 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Tue, 25 Oct 2022 14:58:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Abstracts/AsyncServer.php | 3 +-- Config.php | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Abstracts/AsyncServer.php b/Abstracts/AsyncServer.php index ed9b2f8..1f30b63 100644 --- a/Abstracts/AsyncServer.php +++ b/Abstracts/AsyncServer.php @@ -5,7 +5,6 @@ namespace Kiri\Server\Abstracts; use Exception; use Kiri; use Kiri\Abstracts\Config; -use Kiri\Core\Json; use Kiri\Di\ContainerInterface; use Kiri\Exception\ConfigException; use Kiri\Server\Events\OnShutdown; @@ -118,7 +117,7 @@ class AsyncServer implements ServerInterface if (is_null($match)) { throw new NotFindClassException('Unknown server type ' . $config->type); } - $this->server = new $match($config->host, $config->port, SWOOLE_PROCESS, $config->mode); + $this->server = new $match($config->host, $config->port, $config->mode, $config->socket); $this->server->set($this->systemConfig($config, $daemon)); diff --git a/Config.php b/Config.php index 6e26c63..de8c80a 100644 --- a/Config.php +++ b/Config.php @@ -21,7 +21,10 @@ class Config public string $name = ''; - public int $mode = SWOOLE_SOCK_TCP; + + public int $mode = SWOOLE_PROCESS; + + public int $socket = SWOOLE_SOCK_TCP; public array $settings = []; @@ -141,4 +144,20 @@ class Config $this->events = $events; } + /** + * @return int + */ + public function getSocket(): int + { + return $this->socket; + } + + /** + * @param int $socket + */ + public function setSocket(int $socket): void + { + $this->socket = $socket; + } + }