From 268f8665d088540eb034dc1d2633c39b858502aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Tue, 11 Oct 2022 18:28:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kiri-actor/ActorInterface.php | 4 ++-- kiri-actor/ActorProcess.php | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/kiri-actor/ActorInterface.php b/kiri-actor/ActorInterface.php index 3161f2fe..370a0869 100644 --- a/kiri-actor/ActorInterface.php +++ b/kiri-actor/ActorInterface.php @@ -6,9 +6,9 @@ interface ActorInterface { /** - * @param mixed $message + * @param ActorMessage $message * @return void */ - public function process(mixed $message): void; + public function process(ActorMessage $message): void; } diff --git a/kiri-actor/ActorProcess.php b/kiri-actor/ActorProcess.php index b9941e11..7deabcfb 100644 --- a/kiri-actor/ActorProcess.php +++ b/kiri-actor/ActorProcess.php @@ -47,16 +47,17 @@ class ActorProcess extends BaseProcess $actorManager = $this->container->get(ActorManager::class); while (!$this->isStop()) { $read = json_decode($process->read(), true); - if (is_null($read) || !isset($read['event'])) { + if (is_null($read) || !isset($read['category'])) { continue; } - switch ($read['event']) { + $message = new ActorMessage($read['userId'], $read['event'], $read['body']); + switch ($read['category']) { case ActorState::MESSAGE: - $actorManager->write($read['name'], $read['message']); + $actorManager->write($read['name'], $message); break; case ActorState::CREATE: /** @var ActorInterface $actor */ - $actor = $this->container->create($read['class']); + $actor = $this->container->create($read['class'], $read['constrict'], $read['config']); $actorManager->addActor($actor); break; case ActorState::SHUTDOWN: