hammerspoon2-docs
    Preparing search index...

    Namespace bonjour

    Discover and publish Bonjour (mDNS / Zeroconf) network services. Use createSearch() to search the network for services advertised by other devices, and advertise() to advertise your own. The networkServices() convenience function returns a snapshot of all service types currently active on the local network.

    The hs.bonjour.serviceTypes object maps short names to their mDNS strings, e.g. hs.bonjour.serviceTypes.ssh"_ssh._tcp.".

    // Find all SSH services on the local network and resolve each one
    const search = hs.bonjour.createSearch()
    search.findServices('_ssh._tcp.', 'local.', (event, svc, moreComing) => {
    if (event === 'serviceFound') {
    svc.resolve(5, ev => {
    if (ev === 'resolved') console.log(svc.hostname + ':' + svc.port)
    })
    }
    })
    hs.bonjour.advertise('My Web Server', '_http._tcp.', 8080, ev => {
    if (ev === 'published') console.log('Now advertising!')
    else if (ev === 'error') console.error('Advertising failed')
    })
    // Later, to stop:
    hs.bonjour.stopAdvertising('My Web Server', '_http._tcp.')
    hs.bonjour.networkServices(5).then(types => {
    console.log('Active service types: ' + types.join(', '))
    })

    Variables

    serviceTypes

    Functions

    createSearch
    networkServices
    removeSearch
    stopAdvertising