Namespace: eFTL

eFTL

The eFTL library exports a single object called eFTL to the JavaScript root context. Programs use the eFTL object to connect to an eFTL server.
See:

Methods

connect(url, options)

Connect to an eFTL server.

This call returns immediately; connecting continues asynchronously. When the connection is ready to use, the eFTL library calls your onConnect callback, passing an eFTLConnection object that you can use to publish and subscribe.

When a pipe-separated list of URLs is specified this call will attempt a connection to each in turn, in a random order, until one is connected.

A program that uses more than one server channel must connect separately to each channel.

Parameters:
Name Type Description
url string The call connects to the eFTL server at this URL. This can be a single URL, or a pipe ('|') separated list of URLs. URLs can be in either of these forms:
  • ws://host:port/channel
  • wss://host:port/channel
Optionally, URLs can contain the username, password, and/or client identifier:
  • ws://username:password@host:port/channel?clientId=<identifier>
  • wss://username:password@host:port/channel?clientId=<identifier>
options object A JavaScript object holding properties and callbacks.
Properties
Name Type Argument Description
username string <optional>
Connect using this username if not specified with the URL.
password string <optional>
Connect using this password if not specified with the URL.
clientId string <optional>
Connect using this client identifier if not specified with the URL.
autoReconnectAttempts number <optional>
Specify the maximum number of autoreconnect attempts if the connection is lost.
autoReconnectMaxDelay number <optional>
Specify the maximum delay (in milliseconds) between autoreconnect attempts.
maxPendingAcks number <optional>
Specify the maximum number of unacknowledged messages allowed for the client. Once reached the client will stop receiving additional messages until previously received messages are acknowledged.
trustAll boolean <optional>
Specify true to skip eFTL server certificate authentication. This option should only be used during development and testing. See eFTL#setTrustCertificates.
onConnect onConnect <optional>
A new connection to the eFTL server is ready to use.
onError onError <optional>
An error prevented an operation.
onDisconnect onDisconnect <optional>
A connection to the eFTL server has closed.
onReconnect onReconnect <optional>
A connection to the eFTL server has re-opened and is ready to use.
See:

getVersion() → {string}

Get the version of the eFTL Java client library.
Returns:
The version of the eFTL Java client library.
Type
string

setTrustCertificates(certs)

Set the certificates to trust when making a secure connection.

Self-signed server certificates are not supported.

This method is not supported by browsers. Browsers only trust certificate authorities that have been installed by the browser.

Parameters:
Name Type Description
certs string | Buffer | Array.<string> | Array.<Buffer> Trust these certificates.