改名
This commit is contained in:
@@ -65,11 +65,13 @@ class HTTPServerListener extends Abstracts\Server
|
||||
static::$_http->set($settings['settings'] ?? []);
|
||||
static::$_http->on('request', [$reflect, 'onRequest']);
|
||||
static::$_http->on('connect', [$reflect, 'onConnect']);
|
||||
static::$_http->on('disconnect', [$reflect, 'onDisconnect']);
|
||||
|
||||
$reflect->setEvents(Constant::DISCONNECT, $settings['events'][Constant::DISCONNECT] ?? null);
|
||||
static::$_http->on('close', [$reflect, 'onClose']);
|
||||
if (swoole_version() >= '4.7.0') {
|
||||
static::$_http->on('disconnect', [$reflect, 'onDisconnect']);
|
||||
$reflect->setEvents(Constant::DISCONNECT, $settings['events'][Constant::DISCONNECT] ?? null);
|
||||
}
|
||||
$reflect->setEvents(Constant::CLOSE, $settings['events'][Constant::CLOSE] ?? null);
|
||||
$reflect->setEvents(Constant::CONNECT, $settings['events'][Constant::CONNECT] ?? null);
|
||||
|
||||
return static::$_http;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ class TCPServerListener extends Abstracts\Server
|
||||
* @return Server\Port
|
||||
* @throws NotFindClassException
|
||||
* @throws ReflectionException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function instance(Server $server, string $host, int $port, int $mode, ?array $settings = []): Server\Port
|
||||
{
|
||||
@@ -44,13 +45,12 @@ class TCPServerListener extends Abstracts\Server
|
||||
static::$_tcp->set($settings['settings'] ?? []);
|
||||
static::$_tcp->on('receive', [$reflect, 'onReceive']);
|
||||
static::$_tcp->on('connect', [$reflect, 'onConnect']);
|
||||
static::$_tcp->on('close', [$reflect, 'onClose']);
|
||||
if (swoole_version() >= '4.7.0') {
|
||||
static::$_tcp->on('disconnect', [$reflect, 'onDisconnect']);
|
||||
$reflect->setEvents(Constant::DISCONNECT, $settings['events'][Constant::DISCONNECT] ?? null);
|
||||
} else {
|
||||
static::$_tcp->on('close', [$reflect, 'onClose']);
|
||||
$reflect->setEvents(Constant::CLOSE, $settings['events'][Constant::CLOSE] ?? null);
|
||||
}
|
||||
$reflect->setEvents(Constant::CLOSE, $settings['events'][Constant::CLOSE] ?? null);
|
||||
$reflect->setEvents(Constant::RECEIVE, $settings['events'][Constant::RECEIVE] ?? null);
|
||||
$reflect->setEvents(Constant::CONNECT, $settings['events'][Constant::CONNECT] ?? null);
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ class WebSocketServerListener extends Abstracts\Server
|
||||
*/
|
||||
public function onConnect(Server $server, int $fd)
|
||||
{
|
||||
$this->runEvent(Constant::MESSAGE, fn() => $server->confirm($fd), [$server, $fd]);
|
||||
$this->runEvent(Constant::CONNECT, fn() => $server->confirm($fd), [$server, $fd]);
|
||||
}
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ class WebSocketServerListener extends Abstracts\Server
|
||||
*/
|
||||
public function onClose(Server $server, int $fd)
|
||||
{
|
||||
$this->runEvent(Constant::MESSAGE, fn() => $server->confirm($fd), [$server, $fd]);
|
||||
$this->runEvent(Constant::CLOSE, fn() => $server->confirm($fd), [$server, $fd]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user