Horizon Official Technical Documentation
|
|
Connector object that allows connecting to remote endpoints. More...
#include <Connector.hpp>
Public Types | |
typedef std::function< void(std::string &, std::shared_ptr< tcp::socket >, uint32_t)> | ConnectorCallback |
Public Member Functions | |
Connector (std::string const &connection_name, Server *server, std::string const &connect_ip, uint16_t port) | |
Connector contructor. More... | |
Connector () | |
Destructor of the object that handles joining of all socket polling threads. More... | |
void | connect_with_callback (ConnectorCallback callback, int connections=1) |
Attempts connections to the remote endpoint that the object was initiated with. More... | |
void | set_socket_factory (std::function< std::pair< std::shared_ptr< tcp::socket >, uint32_t >()> &&func) |
Sets a socket factory method that provides a socket for new connections. More... | |
Private Member Functions | |
std::pair< std::shared_ptr< tcp::socket >, uint32_t > | default_socket_factory () |
Private Attributes | |
Server * | server |
std::string | _connection_name |
tcp::endpoint | _endpoint |
std::function< std::pair< std::shared_ptr< tcp::socket >, uint32_t >()> | _socket_factory |
Connector object that allows connecting to remote endpoints.
Connections are passed to network connected threads that handle them separately from accepted threads.
typedef std::function<void(std::string &, std::shared_ptr<tcp::socket>, uint32_t)> Horizon::Networking::Connector::ConnectorCallback |
|
inline |
Connector contructor.
[in|out] | connection_name constant reference to the name string of the connection being created. | |
[in|out] | server pointer to the server object that is instantiating the connection. | |
[in|out] | connect_ip constant reference to the ip string of the endpoint to connect to. | |
[in] | port | port number of the endpoint to connect to. |
|
inline |
Destructor of the object that handles joining of all socket polling threads.
|
inline |
Attempts connections to the remote endpoint that the object was initiated with.
The responsibilities of this method are - 1) Attempt to open connections to an endpoint and retry on failure. 2) Execute callbacks to functions that handle the ownership of the connected socket. 3) Start threads that execute state-verification checks of each connection.
[in] | callback | the callback function that handles socket ownership. |
[in] | connections | the number of connections to the endpoint that will be initiated and handled. |
References _connection_name, _endpoint, _socket_factory, and HLog.
|
inlineprivate |
|
inline |
Sets a socket factory method that provides a socket for new connections.
References _socket_factory.
|
private |
Referenced by connect_with_callback().
|
private |
Referenced by connect_with_callback().
|
private |
Referenced by connect_with_callback(), and set_socket_factory().
|
private |