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