AMPS C/C++ Client Class Reference AMPS C/C++ Client Version 5.3.5.6

Public Member Functions | List of all members
AMPS::DefaultServerChooser Class Reference

A server chooser that rotates through multiple URIs, in order. More...

`#include <DefaultServerChooser.hpp>`

Inheritance diagram for AMPS::DefaultServerChooser:

## Public Member Functions
| DefaultServerChooser ()
| Default constructor which initializes an empty DefaultServerChooser.
virtual std::string | getCurrentURI ()
| Returns the current URI. More...
void | add (const std::string &uri_)
| Adds the given URI to self's list of URIs. More...
template<class T >
void | addAll (const T &uriContainer_)
| Adds the given URIs to self's list of URIs. More...
void | remove (const std::string &)
| Removes the given URI from self's list of URIs if found. More...
virtual Authenticator & | getCurrentAuthenticator ()
| Returns the Authenticator instance associated with the current URI. More...
virtual void | reportFailure (const AMPSException &exception_, const ConnectionInfo &)
| Called by HAClient when an error occurs connecting to the current URI, and/or when an error occurs logging on. More...
virtual std::string | getError ()
| Called by HAClient when no servers are available to provide a more detailed error message in the exception message. More...
virtual void | reportSuccess (const ConnectionInfo &)
| Called by the HAClient when successfully connected and logged on to the current instance. More...
virtual void | next ()
| Advance the server chooser to the next server in the list, starting over with the first server when the chooser reaches the end of the list.
| ~DefaultServerChooser ()
| Destroy self.

## Detailed Description

A server chooser that rotates through multiple URIs, in order.

Used by HAClient to pick an initial server and also to pick a server if there is a failure.

## Member Function Documentation

## ◆ add()

void AMPS::DefaultServerChooser::add | ( | const std::string & | uri_ | ) |
| inline virtual

Adds the given URI to self's list of URIs.

Parameters

  uri_ | The URI to add to self.

Implements AMPS::ServerChooserImpl.

## ◆ addAll()

template<class T >

void AMPS::DefaultServerChooser::addAll | ( | const T & | uriContainer_ | ) |
| inline

Adds the given URIs to self's list of URIs.

Parameters

  uriContainer_ | The URIs to add to self.

## ◆ getCurrentAuthenticator()

virtual Authenticator& AMPS::DefaultServerChooser::getCurrentAuthenticator | ( |  | ) |
| inline virtual

Returns the Authenticator instance associated with the current URI.

Returns
  The DefaultAuthenticator instance

Implements AMPS::ServerChooserImpl.

## ◆ getCurrentURI()

virtual std::string AMPS::DefaultServerChooser::getCurrentURI | ( |  | ) |
| inline virtual

Returns the current URI.

Returns
  The current URI or empty string if no server is available.

Implements AMPS::ServerChooserImpl.

## ◆ getError()

virtual std::string AMPS::DefaultServerChooser::getError | ( |  | ) |
| inline virtual

Called by HAClient when no servers are available to provide a more detailed error message in the exception message.

This implementation returns an empty string.

Returns
  The detailed error message.

Reimplemented from AMPS::ServerChooserImpl.

## ◆ remove()

void AMPS::DefaultServerChooser::remove | ( | const std::string & |  | ) |
| inline virtual

Removes the given URI from self's list of URIs if found.

For DefaultServerChooser, this method has no effect.

Implements AMPS::ServerChooserImpl.

## ◆ reportFailure()

virtual void AMPS::DefaultServerChooser::reportFailure | ( | const AMPSException & | exception_,
|  | const ConnectionInfo & |
| ) |  |
| inline virtual

Called by HAClient when an error occurs connecting to the current URI, and/or when an error occurs logging on.

Advance the current URI to the next one in a list

Parameters

  exception_ | The exception associated with the failure.

Implements AMPS::ServerChooserImpl.

## ◆ reportSuccess()

virtual void AMPS::DefaultServerChooser::reportSuccess | ( | const ConnectionInfo & |  | ) |
| inline virtual

Called by the HAClient when successfully connected and logged on to the current instance.

This implementation does nothing.

Implements AMPS::ServerChooserImpl.

The documentation for this class was generated from the following file:

- include/amps/DefaultServerChooser.hpp