devices = []; // Create the request $request = new MSearchRequest(); $request->setSearchType($search_type); $request->setMaxWait($timeout-1); // Send the request and wait for responses $responses = $endpoint->send($request, $timeout); foreach ($responses as $response) { // Add the relevant responses to the list if ($response instanceof MSearchResponse) { $device = Device::createFromSchema($response->getLocation(), $response->getIp()); $this->devices[] = $device; } } return count($this->devices); } public function getIterator() { return new ArrayIterator($this->devices); } }