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

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

Abstract base class for choosing amongst multiple URIs for both the initial connection and reconnection. More...

`#include <ServerChooser.hpp>`

## Public Member Functions
std::string | getCurrentURI ()
| Returns the current URI. More...
Authenticator & | getCurrentAuthenticator ()
| Returns the Authenticator instance associated with the current URI. More...
void | reportFailure (const AMPSException &exception_, const ConnectionInfo &info_)
| Called by HAClient when an error occurs connecting to the current URI, and/or when an error occurs logging on. More...
std::string | getError ()
| Provides additional detail to be included in an exception thrown when the AMPS instance(s) are not available. More...
void | reportSuccess (const ConnectionInfo &info_)
| Called by the HAClient when successfully connected and logged on to the current instance. More...
ServerChooser & | add (const std::string &uri_)
| Add a server to a server chooser if its policy permits. More...
void | remove (const std::string &uri_)
| Remove a server from a server chooser if its policy permits. More...

## Detailed Description

Abstract base class for choosing amongst multiple URIs for both the initial connection and reconnection.

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

## Member Function Documentation

## ◆ add()

ServerChooser& AMPS::ServerChooser::add | ( | const std::string & | uri_ | ) |
| inline

Add a server to a server chooser if its policy permits.

Parameters

  uri_ | The URI of the server to add

## ◆ getCurrentAuthenticator()

Authenticator& AMPS::ServerChooser::getCurrentAuthenticator | ( |  | ) |
| inline

Returns the Authenticator instance associated with the current URI.

Returns
  An Authenticator or NULL if none is required for logon.

## ◆ getCurrentURI()

std::string AMPS::ServerChooser::getCurrentURI | ( |  | ) |
| inline

Returns the current URI.

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

## ◆ getError()

std::string AMPS::ServerChooser::getError | ( |  | ) |
| inline

Provides additional detail to be included in an exception thrown when the AMPS instance(s) are not available.

Called by the HAClient when creating an exception.

Returns
  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.

## ◆ remove()

void AMPS::ServerChooser::remove | ( | const std::string & | uri_ | ) |
| inline

Remove a server from a server chooser if its policy permits.

Parameters

  uri_ | The URI of the server to remove

## ◆ reportFailure()

void AMPS::ServerChooser::reportFailure | ( | const AMPSException & | exception_,
|  | const ConnectionInfo & | info_
| ) |  |
| inline

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

Implementors will likely advance the current URI to the next one in a list, or choose to stay with the current one, based on the exception type.

Parameters

  exception_ | The exception associated with the failure.
  info_ | a map of information about the connection at time of failure

## ◆ reportSuccess()

void AMPS::ServerChooser::reportSuccess | ( | const ConnectionInfo & | info_ | ) |
| inline

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

Parameters

  info_ | information about the successful connection

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

- include/amps/ServerChooser.hpp