Files
kiri-core/HttpServer/Events/OnClose.php
T
as2252258@163.com b30abb50d5 modify
2021-07-11 04:52:28 +08:00

39 lines
596 B
PHP

<?php
declare(strict_types=1);
namespace HttpServer\Events;
use Exception;
use HttpServer\Abstracts\Callback;
use Snowflake\Event;
use Swoole\Server;
/**
* Class OnClose
* @package HttpServer\Events
*
*/
class OnClose extends Callback
{
/**
* @param Server $server
* @param int $fd
* @throws Exception
*/
public function onHandler(Server $server, int $fd)
{
try {
defer(fn() => fire(Event::SYSTEM_RESOURCE_RELEASES));
Event::trigger(Event::SERVER_ON_CLOSE, [$server, $fd]);
} catch (\Throwable $exception) {
$this->addError($exception, 'throwable');
}
}
}