private function discoverDevices(SocketInterface $socket)
    {
        $this->collection->getLogger()->info("discovering devices...");

        $response = $socket->request();

        $search = "urn:schemas-upnp-org:device:ZonePlayer:1";

        $devices = [];
        foreach (explode("\r\n\r\n", $response) as $reply) {
            if (!$reply) {
                continue;
            }

            # Only attempt to parse responses from Sonos speakers
            if (strpos($reply, $search) === false) {
                continue;
            }

            $data = [];
            foreach (explode("\r\n", $reply) as $line) {
                if (!$pos = strpos($line, ":")) {
                    continue;
                }
                $key = strtolower(substr($line, 0, $pos));
                $val = trim(substr($line, $pos + 1));
                $data[$key] = $val;
            }
            $devices[] = $data;
        }

        $unique = [];
        foreach ($devices as $device) {
            if ($device["st"] !== $search) {
                continue;
            }
            if (in_array($device["usn"], $unique)) {
                continue;
            }
            $this->collection->getLogger()->info("found device: {usn}", $device);

            $unique[] = $device["usn"];

            $url = parse_url($device["location"]);
            $this->collection->addIp($url["host"]);
        }
    }
private function discoverDevices(SocketInterface $socket)
    {
        $this->collection->getLogger()->info("discovering devices...");

        $response = $socket->request();

        $search = "urn:schemas-upnp-org:device:ZonePlayer:1";

        $devices = [];
        foreach (explode("\r\n\r\n", $response) as $reply) {
            if (!$reply) {
                continue;
            }

            # Only attempt to parse responses from Sonos speakers
            if (strpos($reply, $search) === false) {
                continue;
            }

            $data = [];
            foreach (explode("\r\n", $reply) as $line) {
                if (!$pos = strpos($line, ":")) {
                    continue;
                }
                $key = strtolower(substr($line, 0, $pos));
                $val = trim(substr($line, $pos + 1));
                $data[$key] = $val;
            }
            $devices[] = $data;
        }

        $unique = [];
        foreach ($devices as $device) {
            if ($device["st"] !== $search) {
                continue;
            }
            if (in_array($device["usn"], $unique)) {
                continue;
            }
            $this->collection->getLogger()->info("found device: {usn}", $device);

            $unique[] = $device["usn"];

            $url = parse_url($device["location"]);
            $this->collection->addIp($url["host"]);
        }
    }
private function discoverDevices ( SocketInterface $ socket ) { $ this -> collection -> getLogger ( ) -> info ( "discovering devices..." ) ; $ response = $ socket -> request ( ) ; $ search = "urn:schemas-upnp-org:device:ZonePlayer:1" ; $ devices = [ ] ; foreach ( explode ( "\r\n\r\n" , $ response ) as $ reply ) { if ( ! $ reply ) { continue ; } # Only attempt to parse responses from Sonos speakers if ( strpos ( $ reply , $ search ) === false ) { continue ; } $ data = [ ] ; foreach ( explode ( "\r\n" , $ reply ) as $ line ) { if ( ! $ pos = strpos ( $ line , ":" ) ) { continue ; } $ key = strtolower ( substr ( $ line , 0 , $ pos ) ) ; $ val = trim ( substr ( $ line , $ pos + 1 ) ) ; $ data [ $ key ] = $ val ; } $ devices [ ] = $ data ; } $ unique = [ ] ; foreach ( $ devices as $ device ) { if ( $ device [ "st" ] !== $ search ) { continue ; } if ( in_array ( $ device [ "usn" ] , $ unique ) ) { continue ; } $ this -> collection -> getLogger ( ) -> info ( "found device: {usn}" , $ device ) ; $ unique [ ] = $ device [ "usn" ] ; $ url = parse_url ( $ device [ "location" ] ) ; $ this -> collection -> addIp ( $ url [ "host" ] ) ; } }
Get all the devices on the current network.

@param SocketInterface $socket An instance to send the discovery request via

@return void
Get all the devices on the current network .