Capacitor ZeroConf plugin
npm install capacitor-zeroconfCapacitor ZeroConf plugin
This plugin allows you to browse and publish ZeroConf/Bonjour/mDNS services from applications developed using Ionic's Capacitor.
This is not a background service. When the cordova view is destroyed/terminated, publish and watch operations are stopped.
Android, iOS and Electron platforms are supported.
The has been ported from Cordova ZeroConf Plugin.
``bash`
npm install capacitor-zeroconf
npx cap sync
or
`bash`
yarn add capacitor-zeroconf
yarn cap sync
* addListener('discover', ...)
* getHostname()
* register(...)
* unregister(...)
* stop()
* watch(...)
* unwatch(...)
* close()
* Interfaces
* Type Aliases
`typescript`
addListener(eventName: 'discover', listenerFunc: (result: ZeroConfWatchResult) => void) => Promise
| Param | Type |
| ------------------ | ---------------------------------------------------------------------------------------- |
| eventName | 'discover' |
| listenerFunc | (result: ZeroConfWatchResult) => void |
Returns: Promise<PluginListenerHandle>
--------------------
`typescript`
getHostname() => Promise<{ hostname: string; }>
Returns: Promise<{ hostname: string; }>
--------------------
`typescript`
register(request: ZeroConfRegisterRequest) => Promise
| Param | Type |
| ------------- | --------------------------------------------------------------------------- |
| request | ZeroConfRegisterRequest |
--------------------
`typescript`
unregister(request: ZeroConfUnregisterRequest) => Promise
| Param | Type |
| ------------- | ------------------------------------------------------------------------------- |
| request | ZeroConfUnregisterRequest |
--------------------
`typescript`
stop() => Promise
--------------------
`typescript`
watch(request: ZeroConfWatchRequest, callback?: ZeroConfWatchCallback | undefined) => Promise
| Param | Type |
| -------------- | ----------------------------------------------------------------------- |
| request | ZeroConfWatchRequest |
| callback | ZeroConfWatchCallback |
Returns: Promise<string>
--------------------
`typescript`
unwatch(request: ZeroConfUnwatchRequest) => Promise
| Param | Type |
| ------------- | --------------------------------------------------------------------- |
| request | ZeroConfWatchRequest |
--------------------
`typescript`
close() => Promise
--------------------
#### PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| remove | () => Promise<void> |
#### ZeroConfService
| Prop | Type |
| ------------------- | --------------------------------------- |
| domain | string |
| type | string |
| name | string |
| port | number |
| hostname | string |
| ipv4Addresses | string[] |
| ipv6Addresses | string[] |
| txtRecord | { [key: string]: string; } |
#### ZeroConfRegisterRequest
| Prop | Type |
| ----------- | --------------------------------------- |
| port | number |
| props | { [key: string]: string; } |
#### ZeroConfUnregisterRequest
| Prop | Type |
| ---------- | ------------------- |
| name | string |
#### ZeroConfWatchRequest
| Prop | Type |
| ------------ | ------------------- |
| type | string |
| domain` | string |
#### ZeroConfWatchResult
{ action: ZeroConfWatchAction; service: ZeroConfService; }
#### ZeroConfWatchAction
'added' | 'removed' | 'resolved'
#### ZeroConfWatchCallback
(event: ZeroConfWatchResult): void
#### CallbackID
string
#### ZeroConfUnwatchRequest