改名
This commit is contained in:
@@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
namespace Kiri\Rpc;
|
namespace Kiri\Rpc;
|
||||||
|
|
||||||
|
use Kiri\Exception\ConfigException;
|
||||||
|
use Kiri\Kiri;
|
||||||
|
use ReflectionException;
|
||||||
|
use Server\Constant;
|
||||||
|
use Server\ServerManager;
|
||||||
use Server\SInterface\OnClose;
|
use Server\SInterface\OnClose;
|
||||||
use Server\SInterface\OnConnect;
|
use Server\SInterface\OnConnect;
|
||||||
use Server\SInterface\OnPacket;
|
use Server\SInterface\OnPacket;
|
||||||
@@ -19,6 +24,30 @@ class Service implements OnClose, OnConnect, OnReceive, OnPacket, OnRequest
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ServerManager $manager
|
||||||
|
* @param array $config
|
||||||
|
* @throws ConfigException
|
||||||
|
* @throws ReflectionException
|
||||||
|
*/
|
||||||
|
public static function addRpcListener(ServerManager $manager, array $config)
|
||||||
|
{
|
||||||
|
$config['settings']['enable_unsafe_event'] = true;
|
||||||
|
$config['events'][Constant::RECEIVE] = [Service::class, 'onReceive'];
|
||||||
|
$implements = class_implements(Service::class);
|
||||||
|
if (in_array(OnConnect::class, $implements)) {
|
||||||
|
$config['events'][Constant::CONNECT] = [Service::class, 'onConnect'];
|
||||||
|
}
|
||||||
|
if (in_array(OnClose::class, $implements)) {
|
||||||
|
$config['events'][Constant::DISCONNECT] = [Service::class, 'onDisconnect'];
|
||||||
|
$config['events'][Constant::CLOSE] = [Service::class, 'onClose'];
|
||||||
|
}
|
||||||
|
$manager->addListener(
|
||||||
|
$config['type'], $config['host'], $config['port'], $config['mode'], $config
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Server $server
|
* @param Server $server
|
||||||
* @param int $fd
|
* @param int $fd
|
||||||
|
|||||||
Reference in New Issue
Block a user