new MDNS(instrategy)
Multicast DNS based service & host discovery and registration
Parameters:
Name | Type | Description |
---|---|---|
instrategy |
strategy | a strategy to use for host-dependent operations |
Methods
cancelResolveHost(inResolution)
Cancel a request to resolve a hostname to an address.
Parameters:
Name | Type | Description |
---|---|---|
inResolution |
object | resolution descriptor returned by resolveHost() |
cancelResolveService(inResolution)
Cancel a request to discover a service type.
Parameters:
Name | Type | Description |
---|---|---|
inResolution |
object | resolution descriptor returned by resolveService() |
registerHost(inName, inHost)
Register a host for proxy MDNS A record resolution.
Note we leave names alone, we don't remove .local or anything like that.
Parameters:
Name | Type | Description |
---|---|---|
inName |
string | name to proxy resolve, eg printer.local |
inHost |
string | host to proxy resolve, eg 10.0.1.10 |
registerService(inName, inType, inHost, inPort, inTXTRecord)
Register a service for proxy MDNS PTR record resolution.
Parameters:
Name | Type | Description |
---|---|---|
inName |
string | human readable service name, eg My Printer |
inType |
string | type of service, eg _printer._tcp.local |
inHost |
string | host of service, eg 10.0.1.10 |
inPort |
integer | port number of service, eg 2000 |
inTXTRecord |
string | optional text record to additionally serve |
resolveHost(inName, inCallback) → {object}
Request notification of name to host resolutions.
Parameters:
Name | Type | Description |
---|---|---|
inName |
string | name to resolve, eg printer.local |
inCallback |
function | function to call on resolution |
Returns:
object to provide to unresolveHost() call to cancel
- Type
- object
resolveService(inType, inCallback) → {object}
Request notification of service resolutions.
Parameters:
Name | Type | Description |
---|---|---|
inType |
string | type to resolve, eg _printer._tcp.local |
inCallback |
function | function to call on resolution |
Returns:
object to provide to unresolveService() call to cancel
- Type
- object
start(inCallback)
Start Multicast DNS processing.
Must be called prior to any request for discovery or registration.
Parameters:
Name | Type | Description |
---|---|---|
inCallback |
function | function to be called once startup is complete |
startPolling()
Poll to refresh the type and host tables.
Simplistic, but it works.
The only issue is that the polling period has to be less than TTL.
stop()
Stop Multicast DNS operations.
unregisterHost(inName)
Cancel notification of host resolutions.
Parameters:
Name | Type | Description |
---|---|---|
inName |
string | name to cancel resolution, eg printer.local |
unregisterService(inHost, inPort)
Cancel the advertisement of a service.
Parameters:
Name | Type | Description |
---|---|---|
inHost |
string | host of service to cancel, eg 10.0.1.10 |
inPort |
integer | port number of service to cancel, eg 2000 |