qqq
This commit is contained in:
+17
-22
@@ -85,16 +85,7 @@ trait TraitServer
|
||||
*/
|
||||
private function onPcntlSignal($signal, $callback): void
|
||||
{
|
||||
// if (get_called_class() != CoroutineServer::class) {
|
||||
pcntl_signal(SIGINT, [$this, 'onSigint']);
|
||||
// } else {
|
||||
// Coroutine::create(static function () use ($signal, $callback) {
|
||||
// $data = Coroutine::waitSignal($signal);
|
||||
// if ($data) {
|
||||
// $callback($signal, [true]);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@@ -110,22 +101,13 @@ trait TraitServer
|
||||
/**
|
||||
* @param array $ports
|
||||
* @return array
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function sortService(array $ports): array
|
||||
{
|
||||
$array = [];
|
||||
foreach ($ports as $port) {
|
||||
if ($port['type'] == Constant::SERVER_TYPE_WEBSOCKET) {
|
||||
array_unshift($array, $port);
|
||||
} else if ($port['type'] == Constant::SERVER_TYPE_HTTP) {
|
||||
if (!empty($array) && $array[0]['type'] == Constant::SERVER_TYPE_WEBSOCKET) {
|
||||
$array[] = $port;
|
||||
} else {
|
||||
array_unshift($array, $port);
|
||||
}
|
||||
} else {
|
||||
$array[] = $port;
|
||||
}
|
||||
$array = $this->sort($array, $port);
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
@@ -141,7 +123,21 @@ trait TraitServer
|
||||
$array = [];
|
||||
$ports = $ports['ports'] ?? [];
|
||||
foreach ($ports as $port) {
|
||||
$config = \Kiri::getDi()->make(Config::class, [], $port);
|
||||
$array = $this->sort($array, $port);
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $array
|
||||
* @param $port
|
||||
* @return array
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
private function sort(array $array, $port): array
|
||||
{
|
||||
$config = created(Config::class, [], $port);
|
||||
if ($port['type'] == Constant::SERVER_TYPE_WEBSOCKET) {
|
||||
array_unshift($array, $config);
|
||||
} else if ($port['type'] == Constant::SERVER_TYPE_HTTP) {
|
||||
@@ -153,7 +149,6 @@ trait TraitServer
|
||||
} else {
|
||||
$array[] = $config;
|
||||
}
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
use Swoole\Http\Request;
|
||||
use Swoole\Http\Response;
|
||||
use Kiri\Di\Inject\Service;
|
||||
use const Kiri\Router\ROUTER_TYPE_HTTP;
|
||||
|
||||
class OnRequest implements OnRequestInterface
|
||||
|
||||
Reference in New Issue
Block a user