diff --git a/Server/HTTPServerListener.php b/Server/HTTPServerListener.php index f0a588d5..9949d76f 100644 --- a/Server/HTTPServerListener.php +++ b/Server/HTTPServerListener.php @@ -68,14 +68,15 @@ class HTTPServerListener extends Abstracts\Server static::$_http->set($settings['settings'] ?? []); static::$_http->on('request', [$reflect, 'onRequest']); -// if (swoole_version() >= '4.7.0') { -// static::$_http->on('disconnect', [$reflect, 'onDisconnect']); -// $reflect->setEvents(Constant::DISCONNECT, $settings['events'][Constant::DISCONNECT] ?? null); -// } else { -// static::$_http->on('close', [$reflect, 'onClose']); -// $reflect->setEvents(Constant::CLOSE, $settings['events'][Constant::CLOSE] ?? null); -// } -// $reflect->setEvents(Constant::CONNECT, $settings['events'][Constant::CONNECT] ?? null); + static::$_http->on('connect', [$reflect, 'onConnect']); + if (swoole_version() >= '4.7.0') { + static::$_http->on('disconnect', [$reflect, 'onDisconnect']); + $reflect->setEvents(Constant::DISCONNECT, $settings['events'][Constant::DISCONNECT] ?? null); + } else { + static::$_http->on('close', [$reflect, 'onClose']); + $reflect->setEvents(Constant::CLOSE, $settings['events'][Constant::CLOSE] ?? null); + } + $reflect->setEvents(Constant::CONNECT, $settings['events'][Constant::CONNECT] ?? null); return static::$_http; } @@ -88,8 +89,6 @@ class HTTPServerListener extends Abstracts\Server public function onConnect(Server $server, int $fd) { $this->runEvent(Constant::CONNECT, null, [$server, $fd]); - - $this->_event->dispatch(Event::SYSTEM_RESOURCE_RELEASES); } @@ -137,8 +136,6 @@ class HTTPServerListener extends Abstracts\Server public function onDisconnect(Server $server, int $fd) { $this->runEvent(Constant::DISCONNECT, null, [$server, $fd]); - -// $this->_event->dispatch(Event::SYSTEM_RESOURCE_RELEASES); } @@ -150,8 +147,6 @@ class HTTPServerListener extends Abstracts\Server public function onClose(Server $server, int $fd) { $this->runEvent(Constant::CLOSE, null, [$server, $fd]); - -// $this->_event->dispatch(Event::SYSTEM_RESOURCE_RELEASES); } }