hammerspoon2-docs
    Preparing search index...

    Class HSBonjourSearch

    Discovers Bonjour services and domains advertised on the local network. Create via hs.bonjour.newSearch(), then call one of the find… methods. Each search type uses its own underlying NetServiceBrowser, so service and domain searches can run concurrently. Restarting any single search type stops only that browser before beginning the new one.

    Event Data Description
    "serviceFound" HSBonjourService A matching service appeared
    "serviceRemoved" HSBonjourService A previously found service disappeared
    "error" error string The search failed
    Event Data Description
    "domainFound" domain string A domain was discovered
    "domainRemoved" domain string A domain disappeared
    "error" error string The search failed
    Index

    Constructors

    Properties

    identifier: string

    A unique identifier for this search object.

    includesPeerToPeer: boolean

    Whether to search over peer-to-peer Bluetooth/Wi-Fi in addition to standard network interfaces. Defaults to false.

    Methods

    • Searches for domains visible to this machine (browsable domains). If a browsable-domain search is already active it is stopped before starting the new one. Service and registration-domain searches are unaffected. The callback receives (event, domain, moreComing).

      Parameters

      • callback: (event: string, domain: string, moreComing: boolean) => void

        Called for each result with event name, domain string, and whether more results are expected

      Returns HSBonjourSearch

      self, for chaining

    • Searches for domains on which this machine can register services. If a registration-domain search is already active it is stopped before starting the new one. Service and browsable-domain searches are unaffected. The callback receives (event, domain, moreComing).

      Parameters

      • callback: (event: string, domain: string, moreComing: boolean) => void

        Called for each result with event name, domain string, and whether more results are expected

      Returns HSBonjourSearch

      self, for chaining

    • Searches for services of the given type in the given domain. If a service search is already active it is stopped before starting the new one. Domain searches are unaffected. The callback receives (event, service, moreComing) — see the type documentation for the complete event table.

      Parameters

      • type: string

        service type string, e.g. "_http._tcp." or "_ssh._tcp."

      • domain: string

        mDNS domain; "local." for the local link, "" for all domains

      • callback: (event: string, service: HSBonjourService, moreComing: boolean) => void

        Called for each result with event name, service object, and whether more results are expected

      Returns HSBonjourSearch

      self, for chaining