/** * Find devices by UPnP multicast message and stores them to cache * * @static * @access public * * @return array Parsed device list */ public static function findDevices() { $discover = self::discover(); $cache = array(); flush(); foreach ($discover as $response) { $device = new Device(); if ($device->initByDiscoveryReponse($response)) { $device->saveToCache(); try { $client = $device->getClient('ConnectionManager'); $protocolInfo = $client->call('GetProtocolInfo'); $sink = $protocolInfo['Sink']; $tmp = explode(',', $sink); $protocols = array(); foreach ($tmp as $protocol) { $t = explode(':', $protocol); if ($t[0] == 'http-get') { $protocols[] = $t[2]; } } } catch (UPnPException $upnpe) { $protocols = array(); } $device->protocolInfo = $protocols; $cache[$device->getId()] = array('name' => $device->getName(), 'services' => $device->getServices(), 'icons' => $device->getIcons(), 'protocols' => $device->getProtocolInfo()); } } self::saveCache($cache); flush(); return $cache; }