mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-04 17:27:00 +00:00
adds client endpoint connection methods
This commit is contained in:
@@ -114,11 +114,22 @@ public:
|
|||||||
* Initiates the opening connection handshake for connection con. Exact
|
* Initiates the opening connection handshake for connection con. Exact
|
||||||
* behavior depends on the underlying transport policy.
|
* behavior depends on the underlying transport policy.
|
||||||
*
|
*
|
||||||
|
* @param con The connection to connect
|
||||||
|
*
|
||||||
* @return The pointer to the connection originally passed in.
|
* @return The pointer to the connection originally passed in.
|
||||||
*/
|
*/
|
||||||
connection_ptr connect(connection_ptr con) {
|
connection_ptr connect(connection_ptr con) {
|
||||||
// transport async_connect
|
// Ask transport to perform a connection
|
||||||
|
transport_type::async_connect(
|
||||||
|
lib::static_pointer_cast<transport_con_type>(con),
|
||||||
|
lib::bind(
|
||||||
|
&type::handle_connect,
|
||||||
|
this,
|
||||||
|
lib::placeholders::_1,
|
||||||
|
lib::placeholders::_2
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
return con;
|
return con;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,9 +138,32 @@ public:
|
|||||||
// connect(...)
|
// connect(...)
|
||||||
private:
|
private:
|
||||||
// handle_connect
|
// handle_connect
|
||||||
void handle_connect(connection_ptr con, const lib::error_code & ec) {
|
void handle_connect(connection_hdl hdl, const lib::error_code & ec) {
|
||||||
// start connection if successful
|
lib::error_code hdl_ec;
|
||||||
// set failure information if not and call con->terminate
|
connection_ptr con = endpoint_type::get_con_from_hdl(hdl,hdl_ec);
|
||||||
|
|
||||||
|
if (hdl_ec == error::bad_connection) {
|
||||||
|
endpoint_type::m_elog.write(log::elevel::fatal,
|
||||||
|
"handle_connect got an invalid handle back");
|
||||||
|
} else if (hdl_ec) {
|
||||||
|
// There was some other unknown error attempting to convert the hdl
|
||||||
|
// to a connection.
|
||||||
|
endpoint_type::m_elog.write(log::elevel::fatal,
|
||||||
|
"handle_connect error in get_con_from_hdl: "+hdl_ec.message());
|
||||||
|
//con->terminate();
|
||||||
|
} else if (ec) {
|
||||||
|
// TODO
|
||||||
|
// Set connection's failure reasons
|
||||||
|
con->terminate();
|
||||||
|
|
||||||
|
endpoint_type::m_elog.write(log::elevel::rerror,
|
||||||
|
"handle_connect error: "+ec.message());
|
||||||
|
} else {
|
||||||
|
endpoint_type::m_alog.write(log::alevel::connect,
|
||||||
|
"Successful connection");
|
||||||
|
|
||||||
|
con->start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user