Options
All
  • Public
  • Public/Protected
  • All
Menu

Provides static methods to publish and find multicast DNS services.

Hierarchy

  • MulticastDnsDiscovery

Index

Constructors

constructor

Methods

Static findMqttBrokerService

  • findMqttBrokerService(timeout?: number, name?: string, type?: string): Promise<MulticastDnsService>
  • Finds the first multicast DNS service publishing Coaty MQTT broker information. Returns a promise that is resolved with the given service object or rejected if the service cannot be discovered within the given timeout interval.

    This function can only be used in a server-side environment (Node.js), not in a browser runtime.

    Parameters

    • Optional timeout: number

      the number of milliseconds after which the returned promise is rejected (defaults to 2147483647)

    • name: string = "Coaty MQTT Broker"

      the name of the mDNS service to find (defaults to Coaty MQTT Broker)

    • type: string = "coaty-mqtt"

      the type of the mDNS service to find (defaults to coaty-mqtt)

    Returns Promise<MulticastDnsService>

Static findMulticastDnsService

  • findMulticastDnsService(name: string, type: string, timeout?: number): Promise<MulticastDnsService>
  • Finds the first multicast DNS service of the given name and type. Returns a promise that is resolved with the given service object or rejected if the service cannot be discovered within the given timeout interval.

    This function can only be used in a server-side environment (Node.js), not in a browser runtime.

    Parameters

    • name: string

      the name of the mDNS service to find

    • type: string
    • timeout: number = 2147483647

      the number of milliseconds after which the returned promise is rejected (optional, default is 2147483647)

    Returns Promise<MulticastDnsService>

Static findWampRouterService

  • findWampRouterService(timeout?: number, name?: string, type?: string): Promise<MulticastDnsService>
  • Finds the first multicast DNS service publishing Coaty WAMP router information. Returns a promise that is resolved with the given service object or rejected if the service cannot be discovered within the given timeout interval.

    This function can only be used in a server-side environment (Node.js), not in a browser runtime.

    Parameters

    • Optional timeout: number

      the number of milliseconds after which the returned promise is rejected (defaults to 2147483647)

    • name: string = "Coaty WAMP Router"

      the name of the mDNS service to find (defaults to Coaty WAMP Router)

    • type: string = "coaty-wamp"

      the type of the mDNS service to find (defaults to coaty-wamp)

    Returns Promise<MulticastDnsService>

Static getLocalIpV4Address

  • getLocalIpV4Address(networkInterface?: string): string
  • deprecated

    since 2.3.0. Use NodeUtils.getLocalIpV4Address() instead.

    Gets the first IPv4 address of the specified network interface of the local machine. If no network interface name is specified, the first IPv4 address of the first network interface that provides an IPv4 address is returned. Returns undefined if no IPv4 address could be looked up.

    This function can only be used in a server-side environment (Node.js), not in a browser runtime.

    Parameters

    • Optional networkInterface: string

    Returns string

Static publishMqttBrokerService

  • publishMqttBrokerService(port?: number, wsPort?: number, name?: string, type?: string, host?: string): Promise<MulticastDnsService>
  • Publish Coaty MQTT broker information using a multicast DNS (a.k.a mDNS, Bonjour) service with the given parameters.

    Note that the host parameter is optional. By default, the local hostname is used (not the local host IP address!). To resolve this hostname, your network DNS system must be configured properly. If this is not the case, you can pass the target IP address of your mDNS service explicitely.

    The function returns a promise that is resolved with the published service object of type MulticastDnsService. If an error occurs while publishing, the promise is rejected.

    The broker's websocket port (ws-port) is published in the TXT record of the service.

    This function can only be used in a server-side environment (Node.js), not in a browser runtime.

    remarks

    If published with default arguments, the FQDN (fully qualified domain name) of the Coaty MQTT broker mDNS service is "Coaty MQTT Broker._coaty-mqtt._tcp.local". Since the used mDNS library does not handle "_services._dns-sd._udp." meta-queries for browsing, Coaty MQTT Broker information can only be discovered if you provide the mDNS service name explicitely.

    Parameters

    • Optional port: number

      the broker's port (default value is 1883)

    • Optional wsPort: number

      the broker's websocket port (default value is 9883)

    • Optional name: string

      the name of the mDNS service (default value is Coaty MQTT Broker)

    • Optional type: string

      the type of the mDNS service (default value is coaty-mqtt)

    • Optional host: string

      the broker IP address to be published with the service (default is local hostname)

    Returns Promise<MulticastDnsService>

Static publishMulticastDnsService

  • publishMulticastDnsService(name: string, type: string, port: number, txtRecord?: {}, host?: string): Promise<MulticastDnsService>
  • Publish a multicast DNS (a.k.a mDNS, Bonjour, Zeroconf) service with the given parameters. Typically used for discovering the Coaty broker/router or for discovering Coaty configuration URLs hosted on a web server. The published mDNS service contains a JSON TXT record including specific connection parameters. The keys and values of these parameters are always strings so you can easily concat them to form a URL, etc.

    Note that the host parameter is optional. By default, the local hostname is used (not the local host IP address!). To resolve this hostname, your network DNS system must be configured properly. If this is not the case, you can pass the target IP address of your mDNS service explicitely.

    The function returns a promise that is resolved with the published service object of type MulticastDnsService. If an error occurs while publishing, the promise is rejected.

    This function can only be used in a server-side environment (Node.js), not in a browser runtime.

    Parameters

    • name: string

      the name of the mDNS service

    • type: string

      the type of the mDNS service

    • port: number

      the port of the mDNS service

    • txtRecord: {} = {}

      the TXT record containing additional key value pairs (optional)

      • [key: string]: string
    • Optional host: string

      the host IP address to be published with the service (optional, defaults to local hostname)

    Returns Promise<MulticastDnsService>

Static publishWampRouterService

  • publishWampRouterService(path?: string, realm?: string, port?: number, name?: string, type?: string, host?: string): Promise<MulticastDnsService>
  • Publish Coaty WAMP router information using a multicast DNS (a.k.a mDNS, Bonjour) service with the given parameters.

    Note that the host parameter is optional. By default, the local hostname is used (not the local host IP address!). To resolve this hostname, your network DNS system must be configured properly. If this is not the case, you can pass the target IP address of your mDNS service explicitely.

    The function returns a promise that is resolved with the published service object of type MulticastDnsService. If an error occurs while publishing, the promise is rejected.

    The WAMP router's URL path (path) and realm (realm) is published in the TXT record of the service.

    This function can only be used in a server-side environment (Node.js), not in a browser runtime.

    remarks

    If published with default arguments, the FQDN (fully qualified domain name) of the WAMP router mDNS service is "Coaty WAMP Broker._coaty-wamp._tcp.local". Since the used mDNS library does not handle "_services._dns-sd._udp." meta-queries for browsing, Coaty WAMP Router information can only be discovered if you provide the mDNS service name explicitely.

    Parameters

    • Optional path: string

      the router's URL path (default value is /)

    • Optional realm: string

      the router's realm (default value is coaty)

    • Optional port: number

      the router's port (default value is 80)

    • Optional name: string

      the name of the mDNS service (default value is Coaty WAMP Router)

    • Optional type: string

      the type of the mDNS service (default value is coaty-wamp)

    • Optional host: string

      the router IP address to be published with the service (default is local hostname)

    Returns Promise<MulticastDnsService>

Static unpublishMulticastDnsServices

  • unpublishMulticastDnsServices(): Promise<any>
  • Unpublish all published multicast DNS services. Returns a promise that is resolved after all services have been unpublished.

    This function can only be used in a server-side environment (Node.js), not in a browser runtime.

    Returns Promise<any>

Generated using TypeDoc