This commit is contained in:
2026-04-17 11:56:44 +08:00
parent 853a9661bc
commit a9f1afb866
+7 -5
View File
@@ -46,8 +46,10 @@ class AsyncServer extends Component implements ServerInterface
$this->container->get(Task::class)->initTaskWorker($this->server); $this->container->get(Task::class)->initTaskWorker($this->server);
} }
foreach ($this->_process as $process) $this->server->addProcess($process); foreach ($this->_process as $process)
foreach ($service as $value) $this->addListener($value); $this->server->addProcess($process);
foreach ($service as $value)
$this->addListener($value);
$this->provider->on(OnServerBeforeStart::class, [$this, 'onSignal']); $this->provider->on(OnServerBeforeStart::class, [$this, 'onSignal']);
} }
@@ -61,7 +63,7 @@ class AsyncServer extends Component implements ServerInterface
{ {
$this->server->shutdown(); $this->server->shutdown();
$this->dispatch->dispatch(new OnShutdown()); $this->dispatch->dispatch(new OnShutdown);
return true; return true;
} }
@@ -84,7 +86,7 @@ class AsyncServer extends Component implements ServerInterface
throw new NotFindClassException('Unknown server type ' . $config->type); throw new NotFindClassException('Unknown server type ' . $config->type);
} }
$this->container->get(StdoutLogger::class)->println('Listen address ' . $config->host . '::' . $config->port); $this->container->get(StdoutLogger::class)->println('Listen address ' . $config->type . ' ' . $config->host . '::' . $config->port);
$this->server = new $match($config->host, $config->port, $config->mode, $config->socket); $this->server = new $match($config->host, $config->port, $config->mode, $config->socket);
$this->server->set($this->systemConfig($config, $daemon)); $this->server->set($this->systemConfig($config, $daemon));
@@ -180,7 +182,7 @@ class AsyncServer extends Component implements ServerInterface
*/ */
public function start(): void public function start(): void
{ {
$this->dispatch->dispatch(new OnServerBeforeStart()); $this->dispatch->dispatch(new OnServerBeforeStart);
$this->server->start(); $this->server->start();
} }
} }