/** * @param InputInterface $input * @param OutputInterface $output * @return integer */ protected function execute(InputInterface $input, OutputInterface $output) { /** @var SsdpResponse[] $services */ $services = []; $server = new SimpleServiceDiscoveryProtocolServer(); $server->addAllowedMulticastAddress('239.255.255.250'); $server->bind(); $client = new SimpleServiceDiscoveryProtocolClient($this->discoverTime); $client->setServer($server); $client->addEvent(EventDiscover::EVENT_NAME, function (EventDiscover $event) use(&$services) { $service = $event->getSsdpResponse(); if (isset($services[$service->getLocation()])) { return; } $services[$service->getLocation()] = $service; printf("%s\n\t<%s>\n\n", $service->getServer(), $service->getLocation()); }); $client->discover($this->discoverTime); return 0; }