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.
Members
-
<static, constant> CONNECTED
-
-
<static, constant> CONNECTING
-
-
<static, constant> DISCONNECTED
-
-
<static, constant> DISCONNECTING
-
-
<static, constant> RECONNECTING
-
-
<static, constant> STARTED
-
-
<static, constant> STARTING
-
-
<static, constant> STOPPED
-
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 urlstring 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
- ws://username:password@host:port/channel?clientId=<identifier>
- wss://username:password@host:port/channel?clientId=<identifier>
optionsobject A JavaScript object holding properties and callbacks. Properties
Name Type Argument Description usernamestring <optional>
Connect using this username if not specified with the URL. passwordstring <optional>
Connect using this password if not specified with the URL. clientIdstring <optional>
Connect using this client identifier if not specified with the URL. autoReconnectAttemptsnumber <optional>
Specify the maximum number of auto-reconnect attempts if the connection is lost. The default value is 256 attempts. autoReconnectMaxDelaynumber <optional>
Specify the maximum delay (in milliseconds) between auto-reconnect attempts. The default value is 30 seconds. maxPendingAcksnumber <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. trustAllboolean <optional>
Specify trueto skip eFTL server certificate authentication. This option should only be used during development and testing. See eFTL#setTrustCertificates.onConnectonConnect <optional>
A new connection to the eFTL server is ready to use. onErroronError <optional>
An error prevented an operation. onDisconnectonDisconnect <optional>
A connection to the eFTL server has closed. onReconnectonReconnect <optional>
A connection to the eFTL server has re-opened and is ready to use. onStateChangeonStateChange <optional>
The connection state has changed. - 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 certsstring | Buffer | Array.<string> | Array.<Buffer> Trust these certificates.