/** * Constructor. * * @param BroadcastEventInterface $event * @param array $metadata */ public function __construct(BroadcastEventInterface $event, array $metadata) { $this->setBroadcastName($event->getBroadcastName()); $this->setBroadcastChannel($event->getBroadcastChannels()); $this->message = $event->getBroadcastPayload(); $this->metadata = $metadata; }
/** * {@inheritdoc} */ public function broadcast(BroadcastEventInterface $event) { $payload = json_encode(array('event' => $event->getBroadcastName(), 'data' => $event->getBroadcastPayload())); foreach ($event->getBroadcastChannels() as $channel) { $this->redis->publish($channel, $payload); } }