This method adds a URI and an optional authenticator for Client to choose from.
chooser.add('wss://server:9005/amps/json');
chooser.add('wss://another_server:9006/amps/json', myAuthenticator);
The URI of the server.
The authenticator object for custom authentication scenarios.
The server chooser object.
This method allows to add as many server choosers as needed. The arguments can be either uri strings or objects that contain uri key, and optionally, the authenticator key.
chooser.addAll(
'wss://server:9005/amps/json',
{uri: 'wss://extra_server:9007/amps/json'},
{uri: 'wss://another_server:9003/amps/json', authenticator: myAuthenticator}
);
either uri strings or objects that contain uri key, and optionally, the authenticator key.
The server chooser object.
This method returns the current authenticator chosen. If no authenticator was chosen yet, returns null.
The current authenticator chosen (if any).
This method returns the current URI chosen. If no URI was chosen yet, returns null.
The current URI chosen (if any).
This method provides additional detail to be included in an exception thrown by when the AMPS instance(s) are not available. Called by the Client when creating an exception.
A string with information about the connection that failed and the reason for the failure. When no further information is available, returns an empty string.
This method is invoked by the Client to indicate a connection failure occurred.
An error object containing an error message.
An object of properties associated with the failed connection.
This method is invoked by the Client to indicate a connection attempt was successful.
An object of properties associated with the successful connection.
This is a simple server chooser that implements the ServerChooser interface. It keeps a list of AMPS instance URIs and Authenticators, and advances to the next one when a failure occurs. You can add any number of URIs to the DefaultServerChooser.
To use the DefaultServerChooser, you add the URIs for the server to choose from, then set the chooser to the Client:
const chooser = new DefaultServerChooser(); chooser.add('wss://server:9005/amps/nvfix'); chooser.add('wss://server-two:9005/amps/nvfix'); const client = new Client('showchooser'); client.serverChooser(chooser); await client.connect();