Implemented notify

This commit is contained in:
2024-03-01 15:20:54 +01:00
parent f849ac481a
commit 6f49b69a66
4 changed files with 60 additions and 4 deletions

View File

@ -109,6 +109,16 @@ class CommandBus implements CommandBusInterface
*/
public function notify(string $event, array $data): void
{
$this->emit(self::EVENT_NOTIFY, [ $event, $data ]);
$json = (new Message(Message::MSGTYPE_NOTIFY, [
'event' => $event,
'data' => $data
]))->toJson();
foreach ($this->connections as $client) {
$client->write($json."\n");
}
}
}