From 78512590033976f56f43424c09a812584f301d72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 31 Aug 2021 19:12:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Annotation/RpcProduct.php | 43 +++++++++++++++++++++++++++++++++++ src/Protocol.php | 37 ++++++++++++++++++++++++++++++ src/RpcManager.php | 32 ++++++++++++++++++++++++++ src/Service.php | 31 ++++++++++++------------- 4 files changed, 127 insertions(+), 16 deletions(-) create mode 100644 src/Annotation/RpcProduct.php create mode 100644 src/Protocol.php create mode 100644 src/RpcManager.php diff --git a/src/Annotation/RpcProduct.php b/src/Annotation/RpcProduct.php new file mode 100644 index 0000000..e97cfb5 --- /dev/null +++ b/src/Annotation/RpcProduct.php @@ -0,0 +1,43 @@ +get($class); + + RpcManager::addCmdHandler($this->cmd, [$class, $method], $this->protocol); + + return parent::execute($class, $method); // TODO: Change the autogenerated stub + } + + +} diff --git a/src/Protocol.php b/src/Protocol.php new file mode 100644 index 0000000..0017460 --- /dev/null +++ b/src/Protocol.php @@ -0,0 +1,37 @@ +confirm($fd); } @@ -97,7 +86,17 @@ class Service implements OnClose, OnConnect, OnReceive, OnPacket, OnRequest */ public function onReceive(Server $server, int $fd, int $reactor_id, string $data): void { - // TODO: Implement onReceive() method. + try { + + // TODO: Implement onReceive() method. + [$cmd, [$body, $protocol]] = Protocol::parse($data); + } catch(\Throwable $throwable){ + + } + + + + }