hammerspoon2-docs
    Preparing search index...

    Class HSBonjourService

    A discovered Bonjour service record. Call resolve() to look up its hostname, port, and addresses. Instances are delivered by an HSBonjourSearch callback. Call resolve() to discover their hostname, port, and addresses, and optionally monitor() to watch for TXT record changes.

    Method Event Extra data
    resolve() "resolved" (none)
    resolve() "stopped" (none)
    resolve() "error" error message string
    monitor() "txtRecord" updated TXT record dict
    Index

    Constructors

    Properties

    addresses: string[]

    IP address strings (IPv4 and/or IPv6) populated after resolve() completes.

    domain: string

    The mDNS domain (almost always "local.").

    hostname: string | null

    The resolved hostname, or null before resolve() completes.

    identifier: string

    A unique identifier assigned to this service object.

    includesPeerToPeer: boolean

    Whether peer-to-peer Bluetooth/Wi-Fi is included in resolution.

    name: string

    The service name (e.g. "My Web Server").

    port: number

    The service port. -1 until resolve() completes.

    txtRecord: Record<string, string> | null

    The TXT record as a {key: value} object, or null if none is available. Populated after resolve() completes or when updated via monitor().

    type: string

    The service type string (e.g. "_http._tcp.").

    Methods

    • Starts monitoring the TXT record for changes. The callback fires whenever the TXT record is updated. Call stopMonitoring() to unsubscribe.

      Parameters

      • callback: (txtRecord: Record<string, string>) => void

        Called when TXT data changes with the updated record

      Returns HSBonjourService

      self, for chaining

    • Resolves the hostname, port, addresses, and TXT record of this service.

      Parameters

      • timeout: number

        seconds before giving up; pass 0 for no timeout

      • callback: (event: string, error?: string) => void

        Called on status changes with event name and optional error message

      Returns HSBonjourService

      self, for chaining