![]() |
Open Lighting Architecture 0.10.9
|
Attempts to open a TCP connection until a failure limit is reached.
The AdvancedTCPConnector attempts to open connections to a endpoint. If the connection fails it will retry according to a given BackOffPolicy.
Limitations:
Public Types | |
| enum | ConnectionState { DISCONNECTED , PAUSED , CONNECTED } |
| The state of a connection. More... | |
Public Member Functions | |
| AdvancedTCPConnector (ola::io::SelectServerInterface *ss, TCPSocketFactoryInterface *socket_factory, const ola::TimeInterval &connection_timeout) | |
| Create a new AdvancedTCPConnector. | |
| void | AddEndpoint (const IPV4SocketAddress &endpoint, BackOffPolicy *backoff_policy, bool paused=false) |
| Add an endpoint to manage a connection to. | |
| void | RemoveEndpoint (const IPV4SocketAddress &endpoint) |
| Remove a IP:Port from the connection manager. This won't close the connection if it's already established. | |
| unsigned int | EndpointCount () const |
| Return the number of connections tracked by this connector. | |
| bool | GetEndpointState (const IPV4SocketAddress &endpoint, ConnectionState *connected, unsigned int *failed_attempts) const |
| Get the state & number of failed_attempts for an endpoint. | |
| void | Disconnect (const IPV4SocketAddress &endpoint, bool pause=false) |
| Mark an endpoint as disconnected. | |
| void | Resume (const IPV4SocketAddress &endpoint) |
| Resume trying to connect to a ip:port pair. | |
| ola::network::AdvancedTCPConnector::AdvancedTCPConnector | ( | ola::io::SelectServerInterface * | ss, |
| TCPSocketFactoryInterface * | socket_factory, | ||
| const ola::TimeInterval & | connection_timeout ) |
Create a new AdvancedTCPConnector.
| ss | the SelectServerInterface to use for scheduling |
| socket_factory | the factory to use for creating new sockets |
| connection_timeout | the timeout for TCP connects. |
| void ola::network::AdvancedTCPConnector::AddEndpoint | ( | const IPV4SocketAddress & | endpoint, |
| BackOffPolicy * | backoff_policy, | ||
| bool | paused = false ) |
Add an endpoint to manage a connection to.
If the IP:Port already exists this won't do anything. When the connection is successful the on_connect callback will be run, and ownership of the TCPSocket object is transferred.
| endpoint | the IPV4SocketAddress to connect to. |
| backoff_policy | the BackOffPolicy to use for this connection. |
| paused | true if we don't want to immediately connect to this peer. |
| void ola::network::AdvancedTCPConnector::Disconnect | ( | const IPV4SocketAddress & | endpoint, |
| bool | pause = false ) |
Mark an endpoint as disconnected.
| endpoint | the IPV4SocketAddress to mark as disconnected. |
| pause | if true, don't immediately try to reconnect. |
| bool ola::network::AdvancedTCPConnector::GetEndpointState | ( | const IPV4SocketAddress & | endpoint, |
| ConnectionState * | connected, | ||
| unsigned int * | failed_attempts ) const |
Get the state & number of failed_attempts for an endpoint.
| endpoint | the IPV4SocketAddress to get the state of. | |
| [out] | connected | the connection state for this endpoint. |
| [out] | failed_attempts | the number of failed connects for this endpoint. |
| void ola::network::AdvancedTCPConnector::RemoveEndpoint | ( | const IPV4SocketAddress & | endpoint | ) |
Remove a IP:Port from the connection manager. This won't close the connection if it's already established.
| endpoint | the IPV4SocketAddress to remove. |
| void ola::network::AdvancedTCPConnector::Resume | ( | const IPV4SocketAddress & | endpoint | ) |
Resume trying to connect to a ip:port pair.
| endpoint | the IPV4SocketAddress to resume connecting for. |