改名
This commit is contained in:
@@ -7,7 +7,6 @@ namespace HttpServer\Events;
|
||||
use Exception;
|
||||
use HttpServer\Abstracts\Callback;
|
||||
use Snowflake\Event;
|
||||
use Snowflake\Snowflake;
|
||||
use Swoole\Server;
|
||||
|
||||
/**
|
||||
@@ -18,36 +17,37 @@ class OnConnect extends Callback
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param Server $server
|
||||
* @param int $fd
|
||||
* @param int $reactorId
|
||||
* @throws Exception
|
||||
*/
|
||||
public function onHandler(Server $server, int $fd, int $reactorId)
|
||||
{
|
||||
try {
|
||||
defer(function () {
|
||||
fire(Event::SYSTEM_RESOURCE_RELEASES);
|
||||
});
|
||||
if (($clientInfo = $server->getClientInfo($fd, $reactorId)) === false) {
|
||||
return;
|
||||
}
|
||||
fire($this->getName($clientInfo), [$server, $fd, $reactorId]);
|
||||
} catch (\Throwable $throwable) {
|
||||
$this->addError($throwable, 'connect');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param Server $server
|
||||
* @param int $fd
|
||||
* @param int $reactorId
|
||||
* @throws Exception
|
||||
*/
|
||||
public function onHandler(Server $server, int $fd, int $reactorId)
|
||||
{
|
||||
var_dump($fd, $reactorId);
|
||||
try {
|
||||
defer(function () {
|
||||
fire(Event::SYSTEM_RESOURCE_RELEASES);
|
||||
});
|
||||
if (($clientInfo = $server->getClientInfo($fd, $reactorId)) === false) {
|
||||
return;
|
||||
}
|
||||
fire($this->getName($clientInfo), [$server, $fd, $reactorId]);
|
||||
} catch (\Throwable $throwable) {
|
||||
$this->addError($throwable, 'connect');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $clientInfo
|
||||
* @return string
|
||||
*/
|
||||
private function getName(array $clientInfo): string
|
||||
{
|
||||
return 'listen ' . $clientInfo['server_port'] . ' ' . Event::SERVER_CONNECT;
|
||||
}
|
||||
/**
|
||||
* @param array $clientInfo
|
||||
* @return string
|
||||
*/
|
||||
private function getName(array $clientInfo): string
|
||||
{
|
||||
return 'listen ' . $clientInfo['server_port'] . ' ' . Event::SERVER_CONNECT;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user