source/lib/VBDiscover.js
// Send an SSDP M-SEARCH discovery request

Send an SSDP M-SEARCH discovery request
Send an SSDP M - SEARCH discovery request
function ssdpSearchRequest(discoveryCallback) {
  const ssdpRequest = new Buffer(
                      'M-SEARCH * HTTP/1.1\r\n' +
                      'HOST: 239.255.255.250:1900\r\n' +
                      'MAN: "ssdp:discover"\r\n' +
                      'ST: roku:ecp\r\n' +
                      'MX: 3\r\n' +
                      '\r\n')
  const searchSocket = dgram.createSocket('udp4')
  searchSocket.on('message', (msg, rinfo) => {
    const ssdpResponse = msg.toString()
    const serialNumber = extract(reSerialNumber, ssdpResponse)
    const ipAddr = extract(reIpAddr, ssdpResponse)
    if (ipAddr && serialNumber) {
      deviceDiscovered(ipAddr, serialNumber, discoveryCallback)
    }
  })
  searchSocket.send(ssdpRequest, 1900, '239.255.255.250')
}
function ssdpSearchRequest ( discoveryCallback ) { const ssdpRequest = new Buffer ( 'M-SEARCH * HTTP/1.1\r\n' + 'HOST: 239.255.255.250:1900\r\n' + 'MAN: "ssdp:discover"\r\n' + 'ST: roku:ecp\r\n' + 'MX: 3\r\n' + '\r\n' ) const searchSocket = dgram . createSocket ( 'udp4' ) searchSocket . on ( 'message' , ( msg , rinfo ) => { const ssdpResponse = msg . toString ( ) const serialNumber = extract ( reSerialNumber , ssdpResponse ) const ipAddr = extract ( reIpAddr , ssdpResponse ) if ( ipAddr && serialNumber ) { deviceDiscovered ( ipAddr , serialNumber , discoveryCallback ) } } ) searchSocket . send ( ssdpRequest , 1900 , '239.255.255.250' ) }
Send an SSDP M-SEARCH discovery request
Send an SSDP M - SEARCH discovery request
// Only add devices that have an ip address and serial number
 // This will trigger an ECP request to get the device details
 // Send the M-SEARCH request to the SSDP multicast group
