This commit is contained in:
2023-04-21 22:26:43 +08:00
parent ada0f49a43
commit f313860436
12 changed files with 25 additions and 135 deletions
+1 -2
View File
@@ -218,8 +218,7 @@ class AsyncServer implements ServerInterface
*/
public function start(): void
{
$processManager = Kiri::getDi()->get(EventDispatch::class);
$processManager->dispatch(new OnServerBeforeStart());
event(new OnServerBeforeStart());
$this->server->start();
}
+1
View File
@@ -90,6 +90,7 @@ abstract class BaseProcess implements OnProcessInterface
/**
* @param $data
* @throws \ReflectionException
*/
protected function onShutdown($data): void
{
-36
View File
@@ -1,36 +0,0 @@
<?php
namespace Kiri\Server\Abstracts;
use Kiri\Di\Context;
class DoWhile
{
private bool $isStop = false;
/**
* @param array|\Closure $handler
* @return void
*/
public static function waite(array|\Closure $handler): void
{
if (Context::exists('stop')) {
return;
}
$handler();
self::waite($handler);
}
/**
* @return void
*/
public static function stop(): void
{
Context::set('stop', 1);
}
}
+2 -2
View File
@@ -164,8 +164,8 @@ trait TraitServer
public function getCoroutineServerClass($type): ?string
{
return match ($type) {
Constant::SERVER_TYPE_BASE, Constant::SERVER_TYPE_TCP, Constant::SERVER_TYPE_UDP => \Swoole\Coroutine\Server::class,
Constant::SERVER_TYPE_HTTP, Constant::SERVER_TYPE_WEBSOCKET => \Swoole\Coroutine\Http\Server::class,
Constant::SERVER_TYPE_BASE, Constant::SERVER_TYPE_TCP, Constant::SERVER_TYPE_UDP => Coroutine\Server::class,
Constant::SERVER_TYPE_HTTP, Constant::SERVER_TYPE_WEBSOCKET => Coroutine\Http\Server::class,
default => null
};
}