This commit is contained in:
2021-07-21 17:55:34 +08:00
parent 503a188dd7
commit ad43351306
3 changed files with 95 additions and 104 deletions
+8 -5
View File
@@ -92,11 +92,14 @@ class Server extends HttpService
*/
private function rpcListener($rpcService)
{
$rpcService['events'][Constant::CONNECT] = [Service::class, 'onConnect'];
$rpcService['events'][Constant::DISCONNECT] = [Service::class, 'onClose'];
$rpcService['events'][Constant::CLOSE] = [Service::class, 'onClose'];
$rpcService['events'][Constant::RECEIVE] = [Service::class, 'onReceive'];
$rpcService['events'][Constant::PACKET] = [Service::class, 'onPacket'];
if (in_array($rpcService['mode'], [SWOOLE_SOCK_UDP, SWOOLE_UDP, SWOOLE_UDP6, SWOOLE_SOCK_UDP6])) {
$rpcService['events'][Constant::PACKET] = [Service::class, 'onPacket'];
} else {
$rpcService['events'][Constant::RECEIVE] = [Service::class, 'onReceive'];
$rpcService['events'][Constant::CONNECT] = [Service::class, 'onConnect'];
$rpcService['events'][Constant::DISCONNECT] = [Service::class, 'onDisconnect'];
$rpcService['events'][Constant::CLOSE] = [Service::class, 'onClose'];
}
$this->manager->addListener($rpcService['type'], $rpcService['host'], $rpcService['port'], $rpcService['mode'], $rpcService);
}