I have used the GeniusesOfSymfony WebsocketBundle to integrate websockets into my system.
I am now trying to push a notification using the following code (this code is located in a symfony command)
protected function execute(InputInterface $input, OutputInterface $output)
{
$messageData = array(
'message' => $input->getArgument('message'),
'title' => $input->getOption('title') === null ? $this->title : $input->getOption('title'),
'timeout' => $input->getOption('timeout') === null ? $this->timeout : $input->getOption('timeout'),
);
$pusher = $this->getContainer()->get('gos_web_socket.zmq.pusher');
$pusher->push($messageData, 'broadcast');
$output->writeln('Message has been sent');
}
This works perfectly. However, how can I check if the push() function has actually pushed my message to the scoket server? I want to be able to output "Message has been sent" only if this is actually true.
Update
The GeniusesOfSymfony documentation learned me that there are two events to check if it has been a success or an error.
gos_web_socket.push_success
gos_web_socket.push_fail
But I think i can't just do:
if ($event('gos_web_socket.push_success')) {
$output->writeLn("Message has been sent");
} else {
$output->writeLn("Message has NOT been sent");
}