diff --git a/Events/OnAfterWorkerStart.php b/Events/OnAfterWorkerStart.php index 9406c72..3a18e47 100644 --- a/Events/OnAfterWorkerStart.php +++ b/Events/OnAfterWorkerStart.php @@ -2,14 +2,17 @@ namespace Kiri\Server\Events; +use Swoole\Server; + class OnAfterWorkerStart { /** + * @param Server $server * @param int $workerId */ - public function __construct(public int $workerId) + public function __construct(public Server $server, public int $workerId) { } diff --git a/Events/OnBeforeWorkerStart.php b/Events/OnBeforeWorkerStart.php index 2cf5b2f..f10e1bc 100644 --- a/Events/OnBeforeWorkerStart.php +++ b/Events/OnBeforeWorkerStart.php @@ -2,10 +2,16 @@ namespace Kiri\Server\Events; +use Swoole\Server; + class OnBeforeWorkerStart { - public function __construct(public int $workerId) + /** + * @param Server $server + * @param int $workerId + */ + public function __construct(public Server $server,public int $workerId) { } diff --git a/Handler/OnServerWorker.php b/Handler/OnServerWorker.php index fd6ee62..8a5c40f 100644 --- a/Handler/OnServerWorker.php +++ b/Handler/OnServerWorker.php @@ -68,13 +68,13 @@ class OnServerWorker extends \Kiri\Server\Abstracts\Server */ public function onWorkerStart(Server $server, int $workerId): void { - $this->dispatch->dispatch(new OnBeforeWorkerStart(server: $server, workerId: $workerId)); + $this->dispatch->dispatch(new OnBeforeWorkerStart($server, $workerId)); if ($workerId < $server->setting['worker_num']) { $this->dispatch->dispatch(new OnWorkerStart($server, $workerId)); } else { $this->dispatch->dispatch(new OnTaskerStart($server, $workerId)); } - $this->dispatch->dispatch(new OnAfterWorkerStart(workerId: $workerId)); + $this->dispatch->dispatch(new OnAfterWorkerStart($server, $workerId)); }