protected function execute(InputInterface $input, OutputInterface $output)
{
// Start listenning
$this->socket->listen($this->port, $this->host);
// Periodically call determining if we should stop or not
$this->loop->addPeriodicTimer($input->getOption('check-interval'), function () use($output) {
if ($this->shouldExitCommand($output)) {
$this->loop->stop();
$this->writeln($output, 'Event loop stopped:' . $this->port);
$this->returnValue = 10;
}
});
// Main loop
$this->writeln($output, 'Starting event loop:' . $this->port);
$this->loop->run();
return $this->returnValue;
}