From 6067f9778bf7e07f9bec40924fc33e1f731dbb2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Thu, 8 Aug 2024 23:28:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=B3=A8=E9=87=8A=EF=BC=8C=E6=A0=BC=E5=BC=8F=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/think-plugs-worker/src/Server.php | 31 ++++++++++++++++++++++- plugin/think-plugs-worker/src/Service.php | 5 ++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/plugin/think-plugs-worker/src/Server.php b/plugin/think-plugs-worker/src/Server.php index 20f742056..d3ee51cda 100644 --- a/plugin/think-plugs-worker/src/Server.php +++ b/plugin/think-plugs-worker/src/Server.php @@ -34,8 +34,21 @@ abstract class Server protected $port = '2346'; protected $option = []; protected $context = []; - protected $event = ['onWorkerStart', 'onConnect', 'onMessage', 'onClose', 'onError', 'onBufferFull', 'onBufferDrain', 'onWorkerReload', 'onWebSocketConnect']; + protected $event = [ + 'onWorkerStart', + 'onConnect', + 'onMessage', + 'onClose', + 'onError', + 'onBufferFull', + 'onBufferDrain', + 'onWorkerReload', + 'onWebSocketConnect' + ]; + /** + * 服务构造方法 + */ public function __construct() { // 实例化 Websocket 服务 @@ -59,13 +72,29 @@ abstract class Server $this->init(); } + /** + * 服务初始化方法 + * @return mixed + */ abstract protected function init(); + /** + * 动态设置属性 + * @param string $name + * @param mixed $value + * @return void + */ public function __set(string $name, $value) { $this->worker->$name = $value; } + /** + * 动态调用方法 + * @param string $method + * @param array $args + * @return void + */ public function __call(string $method, array $args) { call_user_func_array([$this->worker, $method], $args); diff --git a/plugin/think-plugs-worker/src/Service.php b/plugin/think-plugs-worker/src/Service.php index 885e77414..d74059040 100644 --- a/plugin/think-plugs-worker/src/Service.php +++ b/plugin/think-plugs-worker/src/Service.php @@ -21,6 +21,11 @@ namespace plugin\worker; use plugin\worker\command\Worker; use think\admin\Plugin; +/** + * 插件注册服务 + * @class Service + * @package plugin\worker + */ class Service extends Plugin { /**