This commit is contained in:
xl
2024-08-29 17:01:07 +08:00
parent b14b18040b
commit 917e82064a
8 changed files with 34 additions and 75 deletions
+4 -11
View File
@@ -35,13 +35,6 @@ class AsyncServer implements ServerInterface
private ?Server $server = null;
/**
* @var ContainerInterface
*/
#[Container(ContainerInterface::class)]
public ContainerInterface $container;
/**
* @param array $service
* @param int $daemon
@@ -110,7 +103,7 @@ class AsyncServer implements ServerInterface
$config->events[Constant::SHUTDOWN] = [OnServer::class, 'onShutdown'];
}
$this->_listenDump($config);
$this->container->bind(ServerInterface::class, $this->server);
\Kiri::getDi()->bind(ServerInterface::class, $this->server);
}
@@ -123,7 +116,7 @@ class AsyncServer implements ServerInterface
if (!isset($this->server->setting[Constant::OPTION_TASK_WORKER_NUM])) {
return;
}
$this->container->get(Task::class)->initTaskWorker($this->server);
\Kiri::getDi()->get(Task::class)->initTaskWorker($this->server);
}
@@ -170,7 +163,7 @@ class AsyncServer implements ServerInterface
*/
protected function _listenDump(SConfig $config): void
{
$writeln = $this->container->get(OutputInterface::class);
$writeln = \Kiri::getDi()->get(OutputInterface::class);
if ($config->type == Constant::SERVER_TYPE_HTTP) {
$writeln->writeln('Add http port listen ' . $config->host . '::' . $config->port);
} else if ($config->type == Constant::SERVER_TYPE_WEBSOCKET) {
@@ -214,7 +207,7 @@ class AsyncServer implements ServerInterface
{
foreach ($events as $name => $event) {
if (is_array($event) && is_string($event[0])) {
$event[0] = $this->container->get($event[0]);
$event[0] = \Kiri::getDi()->get($event[0]);
}
$base->on($name, $event);
}