This commit is contained in:
2020-10-29 18:17:25 +08:00
parent 6839b64be8
commit 53ae43b79b
198 changed files with 708 additions and 850 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
declare(strict_types=1);
namespace HttpServer\Events;
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
declare(strict_types=1);
namespace HttpServer\Events;
+3 -3
View File
@@ -1,5 +1,5 @@
<?php
declare(strict_types=1);
namespace HttpServer\Events;
@@ -31,7 +31,7 @@ class OnClose extends Callback
public function onHandler(Server $server, int $fd)
{
try {
[$manager, $name] = $this->resovle($server, $fd);
[$manager, $name] = $this->resolve($server, $fd);
if ($manager !== null && !$manager->has($name)) {
$manager->runWith($name, [$fd]);
}
@@ -53,7 +53,7 @@ class OnClose extends Callback
* @return array|null
* @throws Exception
*/
public function resovle($server, $fd)
public function resolve($server, $fd)
{
if ($server instanceof WServer) {
if (!$server->isEstablished($fd)) {
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
declare(strict_types=1);
namespace HttpServer\Events;
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
declare(strict_types=1);
namespace HttpServer\Events;
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
declare(strict_types=1);
namespace HttpServer\Events;
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
declare(strict_types=1);
namespace HttpServer\Events;
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
declare(strict_types=1);
namespace HttpServer\Events;
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
declare(strict_types=1);
namespace HttpServer\Events;
+5 -5
View File
@@ -1,5 +1,5 @@
<?php
declare(strict_types=1);
namespace HttpServer\Events;
@@ -20,12 +20,12 @@ class OnPacket extends Callback
{
/** @var Closure|array */
public $unpack;
/** @var Closure */
public Closure $unpack;
/** @var Closure|array */
public $pack;
/** @var Closure */
public Closure $pack;
/**
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
declare(strict_types=1);
namespace HttpServer\Events;
+5 -5
View File
@@ -1,5 +1,5 @@
<?php
declare(strict_types=1);
namespace HttpServer\Events;
@@ -20,12 +20,12 @@ class OnReceive extends Callback
{
/** @var Closure|array */
public $unpack;
/** @var Closure */
public Closure $unpack;
/** @var Closure|array */
public $pack;
/** @var Closure */
public Closure $pack;
/**
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
declare(strict_types=1);
namespace HttpServer\Events;
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
declare(strict_types=1);
namespace HttpServer\Events;
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
declare(strict_types=1);
namespace HttpServer\Events;
+6 -5
View File
@@ -1,10 +1,12 @@
<?php
declare(strict_types=1);
namespace HttpServer\Events;
use HttpServer\Abstracts\Callback;
use HttpServer\IInterface\Task;
use HttpServer\IInterface\Task as ITask;
use Snowflake\Event;
use Snowflake\Snowflake;
@@ -40,10 +42,9 @@ class OnTask extends Callback
* @param string $data
*
* @return mixed|void
* @throws Exception
* 异步任务
* @throws Exception 异步任务
*/
public function onTask(Server $server, $task_id, $from_id, $data)
public function onTask(Server $server, int $task_id, int $from_id, string $data)
{
$time = microtime(TRUE);
if (empty($data)) {
@@ -102,7 +103,7 @@ class OnTask extends Callback
$finish['class'] = get_class($serialize);
$finish['params'] = $params;
$finish['status'] = 'success';
$finish['info'] = $serialize->handler();
$finish['info'] = $serialize->onHandler();
} catch (\Throwable $exception) {
$finish['status'] = 'error';
$finish['info'] = $this->format($exception);
@@ -119,7 +120,7 @@ class OnTask extends Callback
* @param $data
* @return ITask|null
*/
protected function before($data)
protected function before($data): Task|null
{
if (empty($serialize = unserialize($data))) {
return null;
+5 -1
View File
@@ -1,5 +1,5 @@
<?php
declare(strict_types=1);
namespace HttpServer\Events;
@@ -11,6 +11,10 @@ use Snowflake\Exception\ConfigException;
use Swoole\Coroutine;
use Swoole\Server;
/**
* Class OnWorkerError
* @package HttpServer\Events
*/
class OnWorkerError extends Callback
{
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
declare(strict_types=1);
namespace HttpServer\Events;
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
declare(strict_types=1);
namespace HttpServer\Events;
+5 -1
View File
@@ -1,11 +1,15 @@
<?php
declare(strict_types=1);
namespace HttpServer\Events;
use HttpServer\Abstracts\Callback;
/**
* Class OnWorkerStop
* @package HttpServer\Events
*/
class OnWorkerStop extends Callback
{