HSBonjourService
TypeA 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.
Callback events
| Method | Event | Extra data |
|---|---|---|
resolve() |
"resolved" |
(none) |
resolve() |
"stopped" |
(none) |
resolve() |
"error" |
error message string |
monitor() |
"txtRecord" |
updated TXT record dict |
Properties
txtRecord
[String: String]
The TXT record as a `{key: value}` object, or `null` if none is available.
Populated after `resolve()` completes or when updated via `monitor()`.
Methods
resolve(timeout, callback) -> HSBonjourService
Resolves the hostname, port, addresses, and TXT record of this service.
Declaration
resolve(timeout, callback) -> HSBonjourService
Parameters
| Name | Type | Description |
|---|---|---|
| timeout | number | seconds before giving up; pass `0` for no timeout |
| callback | JSValue | `function(event, data?)` called on status changes |
Returns
HSBonjourService
self, for chaining
Example
service.resolve(5, (ev, err) => {
if (ev === 'resolved') console.log(service.hostname, service.port)
else console.error('Resolve failed:', err)
})
monitor(callback) -> HSBonjourService
Starts monitoring the TXT record for changes. The callback fires whenever
the TXT record is updated.
Call `stopMonitoring()` to unsubscribe.
Declaration
monitor(callback) -> HSBonjourService
Parameters
| Name | Type | Description |
|---|---|---|
| callback | JSValue | `function(txtRecord)` called when TXT data changes |
Returns
HSBonjourService
self, for chaining
Example
service.monitor(txt => console.log('TXT updated:', txt))
stop() -> HSBonjourService
Stops any active resolution.
Declaration
stop() -> HSBonjourService
Returns
HSBonjourService
self, for chaining
Example
service.stop()
stopMonitoring() -> HSBonjourService
Stops TXT record monitoring started by `monitor()`.
Declaration
stopMonitoring() -> HSBonjourService
Returns
HSBonjourService
self, for chaining
Example
service.stopMonitoring()