@@ -136,16 +136,20 @@ await ZeroConf.unregister({
136136<docgen-api >
137137<!-- Update the source file JSDoc comments and rerun docgen to update the docs below-->
138138
139+ ZeroConf/Bonjour/mDNS service discovery and publishing plugin
140+
139141### addListener('discover', ...)
140142
141143``` typescript
142144addListener (eventName : ' discover' , listenerFunc : (result : ZeroConfWatchResult ) => void ) => Promise < PluginListenerHandle >
143145```
144146
145- | Param | Type |
146- | ------------------ | ---------------------------------------------------------------------------------------- |
147- | ** ` eventName ` ** | <code >'discover'</code > |
148- | ** ` listenerFunc ` ** | <code >(result: <a href =" #zeroconfwatchresult " >ZeroConfWatchResult</a >) => ; void</code > |
147+ Listen for service discovery events
148+
149+ | Param | Type | Description |
150+ | ------------------ | ---------------------------------------------------------------------------------------- | ---------------------------------------- |
151+ | ** ` eventName ` ** | <code >'discover'</code > | - Must be 'discover' |
152+ | ** ` listenerFunc ` ** | <code >(result: <a href =" #zeroconfwatchresult " >ZeroConfWatchResult</a >) => ; void</code > | - Callback function for discovery events |
149153
150154** Returns:** <code >Promise< ; <a href =" #pluginlistenerhandle " >PluginListenerHandle</a >> ; </code >
151155
@@ -158,6 +162,8 @@ addListener(eventName: 'discover', listenerFunc: (result: ZeroConfWatchResult) =
158162getHostname () => Promise < { hostname : string ; }>
159163```
160164
165+ Get the device hostname
166+
161167** Returns:** <code >Promise< ; { hostname: string; }> ; </code >
162168
163169--------------------
@@ -169,9 +175,11 @@ getHostname() => Promise<{ hostname: string; }>
169175register (request : ZeroConfRegisterRequest ) => Promise < void >
170176```
171177
172- | Param | Type |
173- | ------------- | --------------------------------------------------------------------------- |
174- | ** ` request ` ** | <code ><a href =" #zeroconfregisterrequest " >ZeroConfRegisterRequest</a ></code > |
178+ Register/publish a service to make it discoverable
179+
180+ | Param | Type | Description |
181+ | ------------- | --------------------------------------------------------------------------- | ------------------------------ |
182+ | ** ` request ` ** | <code ><a href =" #zeroconfregisterrequest " >ZeroConfRegisterRequest</a ></code > | - Service registration details |
175183
176184--------------------
177185
@@ -182,9 +190,11 @@ register(request: ZeroConfRegisterRequest) => Promise<void>
182190unregister (request : ZeroConfUnregisterRequest ) => Promise < void >
183191```
184192
185- | Param | Type |
186- | ------------- | ------------------------------------------------------------------------------- |
187- | ** ` request ` ** | <code ><a href =" #zeroconfunregisterrequest " >ZeroConfUnregisterRequest</a ></code > |
193+ Unregister/unpublish a previously registered service
194+
195+ | Param | Type | Description |
196+ | ------------- | ------------------------------------------------------------------------------- | ----------------------- |
197+ | ** ` request ` ** | <code ><a href =" #zeroconfunregisterrequest " >ZeroConfUnregisterRequest</a ></code > | - Service to unregister |
188198
189199--------------------
190200
@@ -195,6 +205,8 @@ unregister(request: ZeroConfUnregisterRequest) => Promise<void>
195205stop () => Promise < void >
196206```
197207
208+ Stop all service registration/publishing
209+
198210--------------------
199211
200212
@@ -204,10 +216,13 @@ stop() => Promise<void>
204216watch (request : ZeroConfWatchRequest , callback ?: ZeroConfWatchCallback | undefined ) => Promise < CallbackID >
205217```
206218
207- | Param | Type |
208- | -------------- | ----------------------------------------------------------------------- |
209- | ** ` request ` ** | <code ><a href =" #zeroconfwatchrequest " >ZeroConfWatchRequest</a ></code > |
210- | ** ` callback ` ** | <code ><a href =" #zeroconfwatchcallback " >ZeroConfWatchCallback</a ></code > |
219+ Start watching for services of a specific type
220+ Use addListener('discover', ...) to receive the discovered services
221+
222+ | Param | Type | Description |
223+ | -------------- | ----------------------------------------------------------------------- | --------------------------------------------------------- |
224+ | ** ` request ` ** | <code ><a href =" #zeroconfwatchrequest " >ZeroConfWatchRequest</a ></code > | - What services to watch for |
225+ | ** ` callback ` ** | <code ><a href =" #zeroconfwatchcallback " >ZeroConfWatchCallback</a ></code > | - Optional callback (deprecated, use addListener instead) |
211226
212227** Returns:** <code >Promise< ; string> ; </code >
213228
@@ -220,9 +235,11 @@ watch(request: ZeroConfWatchRequest, callback?: ZeroConfWatchCallback | undefine
220235unwatch (request : ZeroConfUnwatchRequest ) => Promise < void >
221236```
222237
223- | Param | Type |
224- | ------------- | --------------------------------------------------------------------- |
225- | ** ` request ` ** | <code ><a href =" #zeroconfwatchrequest " >ZeroConfWatchRequest</a ></code > |
238+ Stop watching for services
239+
240+ | Param | Type | Description |
241+ | ------------- | --------------------------------------------------------------------- | -------------------------------- |
242+ | ** ` request ` ** | <code ><a href =" #zeroconfwatchrequest " >ZeroConfWatchRequest</a ></code > | - What services to stop watching |
226243
227244--------------------
228245
@@ -233,6 +250,8 @@ unwatch(request: ZeroConfUnwatchRequest) => Promise<void>
233250close () => Promise < void >
234251```
235252
253+ Close all operations and cleanup resources
254+
236255--------------------
237256
238257
@@ -246,68 +265,97 @@ close() => Promise<void>
246265| ** ` remove ` ** | <code >() => ; Promise< ; void> ; </code > |
247266
248267
268+ #### ZeroConfWatchResult
269+
270+ Result of a service discovery event
271+
272+ | Prop | Type | Description |
273+ | ------------- | ------------------------------------------------------------------- | ----------------------------- |
274+ | ** ` action ` ** | <code ><a href =" #zeroconfwatchaction " >ZeroConfWatchAction</a ></code > | What happened to the service |
275+ | ** ` service ` ** | <code ><a href =" #zeroconfservice " >ZeroConfService</a ></code > | The service that was affected |
276+
277+
249278#### ZeroConfService
250279
251- | Prop | Type |
252- | ------------------- | --------------------------------------- |
253- | ** ` domain ` ** | <code >string</code > |
254- | ** ` type ` ** | <code >string</code > |
255- | ** ` name ` ** | <code >string</code > |
256- | ** ` port ` ** | <code >number</code > |
257- | ** ` hostname ` ** | <code >string</code > |
258- | ** ` ipv4Addresses ` ** | <code >string[ ] </code > |
259- | ** ` ipv6Addresses ` ** | <code >string[ ] </code > |
260- | ** ` txtRecord ` ** | <code >{ [ key: string] : string; }</code > |
280+ Discovered service information
281+
282+ | Prop | Type | Description |
283+ | ------------------- | --------------------------------------------------------------- | --------------------- |
284+ | ** ` domain ` ** | <code >string</code > | Domain of the service |
285+ | ** ` type ` ** | <code >string</code > | Service type |
286+ | ** ` name ` ** | <code >string</code > | Service name |
287+ | ** ` port ` ** | <code >number</code > | Port number |
288+ | ** ` hostname ` ** | <code >string</code > | Hostname/FQDN |
289+ | ** ` ipv4Addresses ` ** | <code >string[ ] </code > | IPv4 addresses |
290+ | ** ` ipv6Addresses ` ** | <code >string[ ] </code > | IPv6 addresses |
291+ | ** ` txtRecord ` ** | <code ><a href =" #record " >Record</a >< ; string, string> ; </code > | TXT record data |
261292
262293
263294#### ZeroConfRegisterRequest
264295
265- | Prop | Type |
266- | ----------- | --------------------------------------- |
267- | ** ` port ` ** | <code >number</code > |
268- | ** ` props ` ** | <code >{ [ key: string] : string; }</code > |
296+ Request to register/publish a service
297+
298+ | Prop | Type | Description |
299+ | ----------- | --------------------------------------------------------------- | ---------------------------------------------- |
300+ | ** ` port ` ** | <code >number</code > | Port number the service is running on |
301+ | ** ` props ` ** | <code ><a href =" #record " >Record</a >< ; string, string> ; </code > | Additional properties/metadata for the service |
269302
270303
271304#### ZeroConfUnregisterRequest
272305
273- | Prop | Type |
274- | ---------- | ------------------- |
275- | ** ` name ` ** | <code >string</code > |
306+ Request to unregister a published service
307+
308+ | Prop | Type | Description |
309+ | ---------- | ------------------- | --------------------------------- |
310+ | ** ` name ` ** | <code >string</code > | Name of the service to unregister |
276311
277312
278313#### ZeroConfWatchRequest
279314
280- | Prop | Type |
281- | ------------ | ------------------- |
282- | ** ` type ` ** | <code >string</code > |
283- | ** ` domain ` ** | <code >string</code > |
315+ Request to watch for services of a specific type
316+
317+ | Prop | Type | Description |
318+ | ------------ | ------------------- | ------------------------------------------------ |
319+ | ** ` type ` ** | <code >string</code > | Service type (e.g., '_ http._ tcp.', '_ ssh._ tcp.') |
320+ | ** ` domain ` ** | <code >string</code > | Domain to search in (typically 'local.') |
284321
285322
286323### Type Aliases
287324
288325
289- #### ZeroConfWatchResult
326+ #### ZeroConfWatchAction
327+
328+ Actions that can occur during service discovery
290329
291- <code >{ action: < a href = " #zeroconfwatchaction " >ZeroConfWatchAction</ a >; service: < a href = " #zeroconfservice " >ZeroConfService</ a >; } </code >
330+ <code >'added' | 'removed' | 'resolved' </code >
292331
293332
294- #### ZeroConfWatchAction
333+ #### Record
295334
296- <code >'added' | 'removed' | 'resolved'</code >
335+ Construct a type with a set of properties K of type T
336+
337+ <code >{ [ P in K] : T; }</code >
297338
298339
299340#### ZeroConfWatchCallback
300341
342+ Callback function for service discovery events
343+
301344<code >(event: <a href =" #zeroconfwatchresult " >ZeroConfWatchResult</a >): void</code >
302345
303346
304347#### CallbackID
305348
349+ Unique identifier for a watch operation
350+
306351<code >string</code >
307352
308353
309354#### ZeroConfUnwatchRequest
310355
356+ Request to stop watching for services
357+ Same as <a href =" #zeroconfwatchrequest " >ZeroConfWatchRequest</a >
358+
311359<code ><a href =" #zeroconfwatchrequest " >ZeroConfWatchRequest</a ></code >
312360
313361</docgen-api >
0 commit comments