The CiaoService class represents a service which can be advertised on the network.

A service is identified by its fully qualified domain name (FQDN), which consist of the service name, the service type, the protocol and the service domain (.local by default).

The service defines a hostname and a port where the advertised service can be reached.

Additionally, a TXT record can be published, which can contain information (in form of key-value pairs), which might be useful to a querier.

A CiaoService class is always bound to a Responder and can be created using the Responder.createService method in the Responder class. Once the instance is created, advertise can be called to announce the service on the network.

Hierarchy

  • EventEmitter
    • CiaoService

Methods

  • This method start the advertising process of the service:

    • The service name (and hostname) will be probed unique on all interfaces (as defined in RFC 6762 8.1).
    • Once probed unique the service will be announced (as defined in RFC 6762 8.3).

    The returned promise resolves once the last announcement packet was successfully sent on all network interfaces. The promise might be rejected caused by one of the following reasons:

    • A probe query could not be sent successfully
    • Prober could not find a unique service name while trying for a minute (timeout)
    • One of the announcement packets could not be sent successfully

    Returns Promise<void>

  • This method must be called if you want to free the memory used by this service. The service instance is not usable anymore after this call.

    If the service is still announced, the service will first be removed from the network by calling end.

    Returns Promise<void>

  • This method will remove the advertisement for the service on all connected network interfaces. If the service is still in the Probing state, probing will simply be cancelled.

    Returns Promise<void>

    Promise will resolve once the last goodbye packet was sent out

  • Returns string

    The fully qualified domain name of the service, used to identify the service.

  • Returns string

    The current hostname of the service.

  • Returns undefined | string[]

    Array of subtype pointers (undefined if no subtypes are specified).

  • Returns number

    The port the service is advertising for. {@code -1} is returned when the port is not yet set.

  • Sets or updates the port of the service. A new port number can only be set when the service is still UNANNOUNCED. Otherwise, an assertion error will be thrown.

    Parameters

    • port: number

      The new port number.

    Returns void

  • Sets or updates the txt of the service.

    Parameters

    • txt: ServiceTxt

      The updated txt record.

    • silent: boolean = false

      If set to true no announcement is sent for the updated record.

    Returns void