改名
This commit is contained in:
@@ -43,6 +43,11 @@ class TCPServerListener extends Abstracts\Server
|
|||||||
|
|
||||||
/** @var static $reflect */
|
/** @var static $reflect */
|
||||||
$reflect = Snowflake::getDi()->getReflect(static::class)?->newInstance();
|
$reflect = Snowflake::getDi()->getReflect(static::class)?->newInstance();
|
||||||
|
$reflect->setEvents(Constant::DISCONNECT, $settings['events'][Constant::DISCONNECT] ?? 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);
|
||||||
|
|
||||||
static::$_tcp = $server->addlistener($host, $port, $mode);
|
static::$_tcp = $server->addlistener($host, $port, $mode);
|
||||||
if (!(static::$_tcp instanceof Port)) {
|
if (!(static::$_tcp instanceof Port)) {
|
||||||
trigger_error('Port is ' . $host . '::' . $port . ' must is tcp listener type.');
|
trigger_error('Port is ' . $host . '::' . $port . ' must is tcp listener type.');
|
||||||
@@ -51,14 +56,7 @@ class TCPServerListener extends Abstracts\Server
|
|||||||
static::$_tcp->on('receive', [$reflect, 'onReceive']);
|
static::$_tcp->on('receive', [$reflect, 'onReceive']);
|
||||||
static::$_tcp->on('connect', [$reflect, 'onConnect']);
|
static::$_tcp->on('connect', [$reflect, 'onConnect']);
|
||||||
static::$_tcp->on('close', [$reflect, 'onClose']);
|
static::$_tcp->on('close', [$reflect, 'onClose']);
|
||||||
if (swoole_version() >= '4.7.0') {
|
static::$_tcp->on('disconnect', [$reflect, 'onDisconnect']);
|
||||||
static::$_tcp->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::RECEIVE, $settings['events'][Constant::RECEIVE] ?? null);
|
|
||||||
$reflect->setEvents(Constant::CONNECT, $settings['events'][Constant::CONNECT] ?? null);
|
|
||||||
|
|
||||||
return static::$_tcp;
|
return static::$_tcp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ class UDPServerListener extends Abstracts\Server
|
|||||||
|
|
||||||
/** @var static $reflect */
|
/** @var static $reflect */
|
||||||
$reflect = Snowflake::getDi()->getReflect(static::class)->newInstance();
|
$reflect = Snowflake::getDi()->getReflect(static::class)->newInstance();
|
||||||
|
$reflect->setEvents(Constant::PACKET, $settings['events'][Constant::PACKET] ?? null);
|
||||||
|
|
||||||
static::$_udp = $server->addlistener($host, $port, $mode);
|
static::$_udp = $server->addlistener($host, $port, $mode);
|
||||||
if (!(static::$_udp instanceof Port)) {
|
if (!(static::$_udp instanceof Port)) {
|
||||||
@@ -52,8 +53,6 @@ class UDPServerListener extends Abstracts\Server
|
|||||||
static::$_udp->set($settings['settings'] ?? []);
|
static::$_udp->set($settings['settings'] ?? []);
|
||||||
static::$_udp->on('packet', [$reflect, 'onPacket']);
|
static::$_udp->on('packet', [$reflect, 'onPacket']);
|
||||||
|
|
||||||
$reflect->setEvents(Constant::PACKET, $settings['events'][Constant::PACKET] ?? null);
|
|
||||||
|
|
||||||
return static::$_udp;
|
return static::$_udp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,10 @@ class WebSocketServerListener extends Abstracts\Server
|
|||||||
|
|
||||||
/** @var static $reflect */
|
/** @var static $reflect */
|
||||||
$reflect = Snowflake::getDi()->getReflect(static::class)?->newInstance();
|
$reflect = Snowflake::getDi()->getReflect(static::class)?->newInstance();
|
||||||
|
$reflect->setEvents(Constant::CONNECT, $settings['events'][Constant::CONNECT] ?? null);
|
||||||
|
$reflect->setEvents(Constant::HANDSHAKE, $settings['events'][Constant::HANDSHAKE] ?? null);
|
||||||
|
$reflect->setEvents(Constant::MESSAGE, $settings['events'][Constant::MESSAGE] ?? null);
|
||||||
|
$reflect->setEvents(Constant::CLOSE, $settings['events'][Constant::CLOSE] ?? null);
|
||||||
|
|
||||||
static::$_http = $server->addlistener($host, $port, $mode);
|
static::$_http = $server->addlistener($host, $port, $mode);
|
||||||
if (!(static::$_http instanceof Port)) {
|
if (!(static::$_http instanceof Port)) {
|
||||||
@@ -56,11 +60,6 @@ class WebSocketServerListener extends Abstracts\Server
|
|||||||
static::$_http->on('message', [$reflect, 'onMessage']);
|
static::$_http->on('message', [$reflect, 'onMessage']);
|
||||||
static::$_http->on('close', [$reflect, 'onClose']);
|
static::$_http->on('close', [$reflect, 'onClose']);
|
||||||
|
|
||||||
$reflect->setEvents(Constant::CONNECT, $settings['events'][Constant::CONNECT] ?? null);
|
|
||||||
$reflect->setEvents(Constant::HANDSHAKE, $settings['events'][Constant::HANDSHAKE] ?? null);
|
|
||||||
$reflect->setEvents(Constant::MESSAGE, $settings['events'][Constant::MESSAGE] ?? null);
|
|
||||||
$reflect->setEvents(Constant::CLOSE, $settings['events'][Constant::CLOSE] ?? null);
|
|
||||||
|
|
||||||
return static::$_http;
|
return static::$_http;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user