node_mdns icon indicating copy to clipboard operation
node_mdns copied to clipboard

subtypes not being shared on advertisement callbacks?

Open jedahan opened this issue 6 years ago • 0 comments

Not sure if this is a problem with the browser, the advertisement, or my understanding of mdns, but I created a repository to show that this fails:

const mdns = require('mdns')

const servicesStrings = [
  mdns.tcp('http', 'livingroom').toString(),
  mdns.udp('osc', 'livingroom').toString(),
  mdns.tcp('socketio', 'livingroom').toString()
]

console.dir({servicesStrings})

for (let serviceString of servicesStrings) {
  const service = mdns.makeServiceType(serviceString)
  const browser = mdns.createBrowser(service)

  browser.on('serviceUp', ({type}) => {
    const found = servicesStrings.includes(type.toString())
    console.log(`${type.toString()} ${found ? 'found' : 'not found'} in services`)
  })

  browser.start()
}

let port = 3000
for (let serviceString of servicesStrings) {
  const service = mdns.makeServiceType(serviceString)
  const advertisement = mdns.createAdvertisement(service, port++)
  advertisement.start()
}

jedahan avatar Apr 24 '18 00:04 jedahan