2020-09-02 11:38:47 +08:00
|
|
|
<?php
|
2020-10-29 18:17:25 +08:00
|
|
|
declare(strict_types=1);
|
2020-09-02 11:38:47 +08:00
|
|
|
|
|
|
|
|
namespace HttpServer\Events;
|
|
|
|
|
|
|
|
|
|
|
2021-04-08 10:23:01 +08:00
|
|
|
use Exception;
|
2020-09-04 01:05:33 +08:00
|
|
|
use HttpServer\Abstracts\Callback;
|
2020-09-02 11:38:47 +08:00
|
|
|
use Snowflake\Event;
|
|
|
|
|
use Swoole\Server;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class OnClose
|
|
|
|
|
* @package HttpServer\Events
|
2020-11-06 16:48:57 +08:00
|
|
|
*
|
2020-09-02 11:38:47 +08:00
|
|
|
*/
|
|
|
|
|
class OnClose extends Callback
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
2021-06-25 11:20:38 +08:00
|
|
|
/**
|
|
|
|
|
* @param Server $server
|
|
|
|
|
* @param int $fd
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public function onHandler(Server $server, int $fd)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
defer(fn() => fire(Event::SYSTEM_RESOURCE_RELEASES));
|
|
|
|
|
|
2021-07-11 04:31:15 +08:00
|
|
|
Event::trigger(Event::SERVER_ON_CLOSE, [$server, $fd]);
|
2021-06-25 11:20:38 +08:00
|
|
|
} catch (\Throwable $exception) {
|
|
|
|
|
$this->addError($exception, 'throwable');
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-03-08 18:29:59 +08:00
|
|
|
|
2020-09-02 11:38:47 +08:00
|
|
|
}
|