#include <basic_client.h>
Public 型 | |
enum | { MAX_MESG = 8192 } |
Public メソッド | |
BasicClient () | |
init member variables | |
virtual | ~BasicClient () |
virtual destructor. | |
bool | connectTo (const char *hostname, const int port, const long &interval_msec) |
connect to the specified server with timeout value for select() | |
void | run (SoccerAgent *agent) |
program mainloop | |
void | setIntervalMSec (const long &interval_msec) |
set new interval time for select() | |
void | setServerAlive (const bool alive) |
set server status | |
int | setCompressionLevel (const int level) |
set gzip compression level | |
int | sendMessage (const char *msg) |
send raw string to the server | |
int | recvMessage () |
receive server message in the socket queue | |
bool | isServerAlive () const |
check server alive status | |
const char * | message () const |
get recieved message buffer |
This class supplies:
bool rcsc::BasicClient::connectTo | ( | const char * | hostname, | |
const int | port, | |||
const long & | interval_msec | |||
) |
connect to the specified server with timeout value for select()
hostname | server host name | |
port | server port number | |
interval_msec | timeout interval for select() by milli second |
void rcsc::BasicClient::run | ( | SoccerAgent * | agent | ) |
program mainloop
Thie method keep infinite loop while client can estimate server is alive. To handle server message, select() is used. Timeout interval of select() is specified by M_interval_msec member variable. When server message is received, handleMessage() is called. When timeout occurs, handleTimeout() is called. When server is not alive, loop is end and handleExit() is called.
void rcsc::BasicClient::setIntervalMSec | ( | const long & | interval_msec | ) |
set new interval time for select()
interval_msec | new interval by milli second |
void rcsc::BasicClient::setServerAlive | ( | const bool | alive | ) |
set server status
alive | server status flag. if server is dead, this value becomes false. |
int rcsc::BasicClient::setCompressionLevel | ( | const int | level | ) |
set gzip compression level
level | compression level |
int rcsc::BasicClient::sendMessage | ( | const char * | msg | ) |
send raw string to the server
msg | message to be sent |
int rcsc::BasicClient::recvMessage | ( | ) |
receive server message in the socket queue
bool rcsc::BasicClient::isServerAlive | ( | ) | const [inline] |
check server alive status
const char* rcsc::BasicClient::message | ( | ) | const [inline] |
get recieved message buffer