a client sending out commands to a server More...
#include <command_client.hxx>
Public Member Functions | |
command_client (client_connection *_c, long long _command_timeout_usec=command_timeout_usec_default, long long _hello_timeout_usec=hello_timeout_usec_default) | |
virtual | ~command_client () |
void | replace_connection (client_connection *_c) |
replace the connection currently in use with a new one | |
void | send_command (command *cmd, result_container &res) |
send a command to the server and store the result | |
void | set_command_timeout_usec (long long _command_timeout_usec=command_timeout_usec_default) |
void | set_hello_timeout_usec (long long _hello_timeout_usec=hello_timeout_usec_default) |
long long | get_command_timeout_usec (void) |
long long | get_hello_timeout_usec (void) |
bool | is_connection_closed (void) |
t2n_exception * | get_constuctor_exception (void) |
Static Public Attributes | |
static const long long | command_timeout_usec_default = 90000000 |
static const long long | hello_timeout_usec_default = 30000000 |
Private Member Functions | |
void | read_hello () |
read and check the hello message at the beginning of a connection | |
std::string | read_packet (const long long &usec_timeout) |
return a complete packet | |
bool | check_hello (const std::string &hellostr) |
check if a hello message is valid | |
Private Attributes | |
client_connection * | c |
long long | hello_timeout_usec |
long long | command_timeout_usec |
t2n_exception * | constructorException |
a client sending out commands to a server
libt2n::command_client::command_client | ( | client_connection * | _c, | |
long long | _command_timeout_usec = command_timeout_usec_default , |
|||
long long | _hello_timeout_usec = hello_timeout_usec_default | |||
) |
Constructor
_c | connection for this command. Ownership of the pointer is outside. | |
_command_timeout_usec | timeout until the command has to be completed | |
_hello_timeout_usec | timeout until hello has to be received |
References libt2n::connection::add_callback(), c, libt2n::t2n_communication_error::clone(), libt2n::connection::close(), command_timeout_usec, constructorException, hello_timeout_usec, is_connection_closed(), libt2n::new_connection, and read_hello().
libt2n::command_client::~command_client | ( | ) | [virtual] |
Destructor
References constructorException.
bool libt2n::command_client::check_hello | ( | const std::string & | hellostr | ) | [private] |
check if a hello message is valid
hellostr | std::string with the message to check |
true | if the hello is good and complete |
Referenced by read_hello().
long long libt2n::command_client::get_command_timeout_usec | ( | void | ) | [inline] |
References command_timeout_usec.
t2n_exception* libt2n::command_client::get_constuctor_exception | ( | void | ) | [inline] |
References constructorException.
long long libt2n::command_client::get_hello_timeout_usec | ( | void | ) | [inline] |
References hello_timeout_usec.
bool libt2n::command_client::is_connection_closed | ( | void | ) | [inline] |
References c, and libt2n::connection::is_closed().
Referenced by command_client(), and send_command().
void libt2n::command_client::read_hello | ( | ) | [private] |
read and check the hello message at the beginning of a connection
References c, check_hello(), libt2n::connection::fill_buffer(), libt2n::connection::get_packet(), hello_timeout_usec, libt2n::connection::is_closed(), and libt2n::connection::peek_packet().
Referenced by command_client(), and replace_connection().
std::string libt2n::command_client::read_packet | ( | const long long & | usec_timeout | ) | [private] |
return a complete packet
usec_timeout | maximum microseconds to wait until the packet is complete |
packet | data as std::string |
References c, libt2n::connection::fill_buffer(), libt2n::connection::get_packet(), and libt2n::connection::is_closed().
Referenced by send_command().
void libt2n::command_client::replace_connection | ( | client_connection * | _c | ) |
replace the connection currently in use with a new one
_c | pointer to the new connection |
References libt2n::__events_end, libt2n::connection::add_callback(), c, libt2n::connection::get_callback_list(), and read_hello().
Referenced by libt2n::ReconnectIgnoreFailureSocketWrapper::handle().
void libt2n::command_client::send_command | ( | command * | cmd, | |
result_container & | res | |||
) |
send a command to the server and store the result
References c, command_timeout_usec, libt2n::fulldebug, libt2n::client_connection::get_logstream(), is_connection_closed(), read_packet(), and libt2n::connection::write().
void libt2n::command_client::set_command_timeout_usec | ( | long long | _command_timeout_usec = command_timeout_usec_default |
) | [inline] |
References command_timeout_usec.
void libt2n::command_client::set_hello_timeout_usec | ( | long long | _hello_timeout_usec = hello_timeout_usec_default |
) | [inline] |
References hello_timeout_usec.
client_connection* libt2n::command_client::c [private] |
Referenced by command_client(), is_connection_closed(), read_hello(), read_packet(), replace_connection(), and send_command().
long long libt2n::command_client::command_timeout_usec [private] |
Referenced by command_client(), get_command_timeout_usec(), send_command(), and set_command_timeout_usec().
const long long libt2n::command_client::command_timeout_usec_default = 90000000 [static] |
Referenced by command_client(), get_constuctor_exception(), and ~command_client().
long long libt2n::command_client::hello_timeout_usec [private] |
Referenced by command_client(), get_hello_timeout_usec(), read_hello(), and set_hello_timeout_usec().
const long long libt2n::command_client::hello_timeout_usec_default = 30000000 [static] |