2020-08-31 01:27:08 +08:00
|
|
|
<?php
|
2020-10-29 18:17:25 +08:00
|
|
|
declare(strict_types=1);
|
2020-08-31 01:27:08 +08:00
|
|
|
|
2020-09-02 11:38:47 +08:00
|
|
|
namespace HttpServer\Events;
|
2020-08-31 01:27:08 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
use Exception;
|
2020-09-04 01:05:33 +08:00
|
|
|
use HttpServer\Abstracts\Callback;
|
2021-08-11 01:04:57 +08:00
|
|
|
use Kiri\Event;
|
|
|
|
|
use Kiri\Kiri;
|
2020-08-31 01:27:08 +08:00
|
|
|
use Swoole\Server;
|
|
|
|
|
|
2020-12-17 14:09:14 +08:00
|
|
|
/**
|
|
|
|
|
* Class OnFinish
|
|
|
|
|
* @package HttpServer\Events
|
|
|
|
|
*/
|
2020-08-31 01:27:08 +08:00
|
|
|
class OnFinish extends Callback
|
|
|
|
|
{
|
2021-03-01 15:54:38 +08:00
|
|
|
|
|
|
|
|
|
2021-04-23 03:25:03 +08:00
|
|
|
/**
|
|
|
|
|
* @param Server $server
|
|
|
|
|
* @param $task_id
|
|
|
|
|
* @param $data
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public function onHandler(Server $server, $task_id, $data)
|
|
|
|
|
{
|
|
|
|
|
try {
|
2021-05-04 01:33:08 +08:00
|
|
|
defer(fn() => fire(Event::SYSTEM_RESOURCE_RELEASES));
|
|
|
|
|
|
2021-04-23 03:25:03 +08:00
|
|
|
fire(Event::TASK_FINISH, [$task_id, $data]);
|
|
|
|
|
} catch (\Throwable $exception) {
|
|
|
|
|
$this->addError($exception, 'task');
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-31 01:27:08 +08:00
|
|
|
|
|
|
|
|
}
|