This commit is contained in:
2020-12-17 14:09:14 +08:00
parent 672a719dbd
commit 36c1d0502a
151 changed files with 1937 additions and 2848 deletions
-5
View File
@@ -6,10 +6,6 @@ namespace HttpServer\Events;
use Annotation\Route\Socket;
use HttpServer\Abstracts\Callback;
use HttpServer\Route\Annotation\Http;
use HttpServer\Route\Annotation\Tcp;
use HttpServer\Route\Annotation\Websocket;
use HttpServer\Route\Annotation\Websocket as AWebsocket;
use HttpServer\Route\Node;
use Snowflake\Event;
use Snowflake\Exception\ComponentException;
@@ -17,7 +13,6 @@ use Snowflake\Snowflake;
use Swoole\Coroutine;
use Swoole\Server;
use Exception;
use Swoole\Http\Server as HServer;
use Swoole\WebSocket\Server as WServer;
/**
+4
View File
@@ -8,6 +8,10 @@ use Exception;
use HttpServer\Abstracts\Callback;
use Swoole\Server;
/**
* Class OnFinish
* @package HttpServer\Events
*/
class OnFinish extends Callback
{
/**
+4 -5
View File
@@ -7,7 +7,6 @@ namespace HttpServer\Events;
use Annotation\Route\Socket;
use Exception;
use HttpServer\Abstracts\Callback;
use HttpServer\Route\Annotation\Websocket as AWebsocket;
use Snowflake\Event;
use Snowflake\Exception\ComponentException;
use Snowflake\Snowflake;
@@ -62,7 +61,7 @@ class OnHandshake extends Callback
* @param int $code
* @return false
*/
private function disconnect($response, $code = 500)
private function disconnect($response, $code = 500): bool
{
$response->status($code);
$response->end();
@@ -73,10 +72,10 @@ class OnHandshake extends Callback
/**
* @param SRequest $request
* @param SResponse $response
* @return mixed|void
* @throws Exception
* @return void
* @throws ComponentException
*/
public function onHandler(SRequest $request, SResponse $response)
public function onHandler(SRequest $request, SResponse $response): void
{
Coroutine::defer(function () {
fire(Event::EVENT_AFTER_REQUEST);
+2 -3
View File
@@ -4,12 +4,11 @@ declare(strict_types=1);
namespace HttpServer\Events;
use Exception;
use HttpServer\Abstracts\Callback;
use Snowflake\Abstracts\Config;
use Snowflake\Event;
use Snowflake\Snowflake;
use Swoole\Coroutine\System;
use Swoole\Process;
use Swoole\Server;
class OnManagerStart extends Callback
@@ -17,7 +16,7 @@ class OnManagerStart extends Callback
/**
* @param Server $server
* @throws \Exception
* @throws Exception
*/
public function onHandler(Server $server)
{
+2 -1
View File
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace HttpServer\Events;
use Exception;
use HttpServer\Abstracts\Callback;
use Snowflake\Event;
use Snowflake\Snowflake;
@@ -18,7 +19,7 @@ class OnManagerStop extends Callback
/**
* @param $server
* @throws \Exception
* @throws Exception
*/
public function onHandler(Server $server)
{
+1 -2
View File
@@ -6,7 +6,6 @@ namespace HttpServer\Events;
use Closure;
use HttpServer\Abstracts\Callback;
use Snowflake\Core\JSON;
use Snowflake\Event;
use Snowflake\Snowflake;
use Swoole\Server;
@@ -36,7 +35,7 @@ class OnPacket extends Callback
* @return mixed
* @throws Exception
*/
public function onHandler(Server $server, string $data, array $clientInfo)
public function onHandler(Server $server, string $data, array $clientInfo): mixed
{
try {
$data = DataResolve::unpack($this->unpack, $clientInfo['address'], $clientInfo['port'], $data);
+1 -1
View File
@@ -36,7 +36,7 @@ class OnReceive extends Callback
* @return mixed
* @throws Exception
*/
public function onHandler(\Swoole\Server $server, int $fd, int $reID, string $data)
public function onHandler(\Swoole\Server $server, int $fd, int $reID, string $data): mixed
{
try {
$client = $server->getClientInfo($fd, $reID);
-4
View File
@@ -7,13 +7,9 @@ namespace HttpServer\Events;
use Exception;
use HttpServer\Abstracts\Callback;
use HttpServer\Exception\ExitException;
use HttpServer\Http\Context;
use HttpServer\Http\Request as HRequest;
use HttpServer\Http\Response as HResponse;
use HttpServer\Route\Node;
use HttpServer\Service\Http;
use ReflectionException;
use Snowflake\Abstracts\Config;
use Snowflake\Core\JSON;
use Snowflake\Event;
use Snowflake\Exception\ComponentException;
-8
View File
@@ -6,18 +6,10 @@ namespace HttpServer\Events;
use Exception;
use HttpServer\Abstracts\Callback;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use Snowflake\Abstracts\Config;
use Snowflake\Core\JSON;
use Snowflake\Error\Logger;
use Snowflake\Event;
use Snowflake\Exception\ComponentException;
use Snowflake\Exception\ConfigException;
use Snowflake\Snowflake;
use Swoole\Coroutine;
use Swoole\Server;
use Closure;
/**
* Class OnShutdown
+2 -3
View File
@@ -4,12 +4,11 @@ declare(strict_types=1);
namespace HttpServer\Events;
use Exception;
use HttpServer\Abstracts\Callback;
use Snowflake\Abstracts\Config;
use Snowflake\Event;
use Snowflake\Snowflake;
use Swoole\Coroutine\System;
use Swoole\Process;
use Swoole\Server;
class OnStart extends Callback
@@ -17,7 +16,7 @@ class OnStart extends Callback
/**
* @param Server $server
* @throws \Exception
* @throws Exception
*/
public function onHandler(Server $server)
{
-5
View File
@@ -6,15 +6,10 @@ namespace HttpServer\Events;
use Exception;
use HttpServer\Abstracts\Callback;
use HttpServer\Route\Annotation\Websocket as AWebsocket;
use HttpServer\Service\Http;
use HttpServer\Service\Websocket;
use Snowflake\Abstracts\Config;
use Snowflake\Error\Logger;
use Snowflake\Event;
use Snowflake\Exception\ConfigException;
use Snowflake\Snowflake;
use Swoole\Coroutine\System;
use Swoole\Server;
/**
+2 -1
View File
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace HttpServer\Events;
use Exception;
use HttpServer\Abstracts\Callback;
/**
@@ -17,7 +18,7 @@ class OnWorkerStop extends Callback
/**
* @param $server
* @param $worker_id
* @throws \Exception
* @throws Exception
*/
public function onHandler($server, $worker_id)
{
+2 -2
View File
@@ -65,11 +65,11 @@ class DataResolve
* @param $address
* @param $port
* @param $data
* @return array|mixed
* @return mixed
* @throws NotFindClassException
* @throws ReflectionException
*/
private static function callbackResolve($callback, $address, $port, $data)
private static function callbackResolve($callback, $address, $port, $data): mixed
{
if ($callback instanceof Closure) {
if (empty($address) && empty($port)) {