This commit is contained in:
2020-12-15 18:25:03 +08:00
parent edad73659a
commit d8bcf9ebe0
4 changed files with 1 additions and 52 deletions
-31
View File
@@ -67,35 +67,4 @@ class OnClose extends Callback
$logger->insert();
}
}
/**
* @param $server
* @param $fd
* @return array|null
* @throws Exception
*/
public function resolve($server, $fd): ?array
{
if ($server instanceof WServer) {
if (!$server->isEstablished($fd)) {
return [null, null];
}
$router = Snowflake::app()->getRouter();
$node = $router->search(Socket::HANDSHAKE . '::' . null, 'sw::socket');
if ($node === null) {
return [null, null];
}
return $node->dispatch();
} else if ($server instanceof HServer) {
$manager = Snowflake::app()->annotation->http;
$name = $manager->getName(Http::CLOSE);
} else {
$manager = Snowflake::app()->annotation->tcp;
$name = $manager->getName(Tcp::CLOSE);
}
return [$manager, $name];
}
}
+1 -7
View File
@@ -198,22 +198,16 @@ class Node extends Application
* @return null|array
* @throws Exception
*/
private function getReflect(string $controller, string $action)
private function getReflect(string $controller, string $action): ?array
{
try {
$reflect = Snowflake::getDi()->getReflect($controller);
if (!$reflect->isInstantiable()) {
throw new Exception($controller . ' Class is con\'t Instantiable.');
}
if (!empty($action) && !$reflect->hasMethod($action)) {
throw new Exception('method ' . $action . ' not exists at ' . $controller . '.');
}
$annotation = Snowflake::app()->annotation->http;
if (!empty($annotations = $annotation->getAnnotation(Http::class))) {
$annotation->read($this, $reflect, $action, $annotations);
}
return [$reflect->newInstance(), $action];
} catch (\Throwable $exception) {
$this->_error = $exception->getMessage();
-10
View File
@@ -588,16 +588,6 @@ class Router extends Application implements RouterInterface
*/
public function loadRouterSetting()
{
$prefix = APP_PATH . 'app/Http/';
/** @var Http $annotation */
$annotation = Snowflake::app()->annotation;
$annotation = $annotation->http;
$annotation->registration_notes($prefix . 'Interceptor', 'App\Http\Interceptor');
$annotation->registration_notes($prefix . 'Limits', 'App\Http\Limits');
$annotation->registration_notes($prefix . 'Middleware', 'App\Http\Middleware');
$this->loadRouteDir(APP_PATH . '/routes');
}
-4
View File
@@ -207,10 +207,6 @@ class Server extends Application
return;
}
// $attributes = Snowflake::app()->getAttributes();
// $attributes->readControllers(CONTROLLER_PATH, 'App\Http\Controllers', 'controllers');
// $attributes->readControllers(SOCKET_PATH, 'App\Websocket', 'sockets');
$processes = Config::get('processes');
if (!empty($processes) && is_array($processes)) {
$this->deliveryProcess(merge($processes, $this->process));