Kyoto Tycoon
Public Types | Public Member Functions
kyototycoon::RPCClient Class Reference

RPC client. More...

#include <ktrpc.h>

List of all members.

Public Types

enum  ReturnValue {
  RVSUCCESS, RVENOIMPL, RVEINVALID, RVELOGIC,
  RVETIMEOUT, RVEINTERNAL, RVENETWORK, RVEMISC = 15
}
 Return value. More...

Public Member Functions

 RPCClient ()
 Default constructor.
 ~RPCClient ()
 Destructor.
bool open (const std::string &host="", int32_t port=DEFPORT, double timeout=-1)
 Open the connection.
bool close (bool grace=true)
 Close the connection.
ReturnValue call (const std::string &name, const std::map< std::string, std::string > *inmap=NULL, std::map< std::string, std::string > *outmap=NULL)
 Call a remote procedure.
const std::string expression ()
 Get the expression of the socket.
HTTPClientreveal_core ()
 Reveal the internal HTTP client.

Detailed Description

RPC client.

Note:
Although all methods of this class are thread-safe, its instance does not have mutual exclusion mechanism. So, multiple threads must not share the same instance and they must use their own respective instances.

Member Enumeration Documentation

Return value.

Enumerator:
RVSUCCESS 

success

RVENOIMPL 

not implemented

RVEINVALID 

invalid operation

RVELOGIC 

logical inconsistency

RVETIMEOUT 

timeout

RVEINTERNAL 

internal error

RVENETWORK 

network error

RVEMISC 

miscellaneous error


Constructor & Destructor Documentation

Default constructor.

Destructor.


Member Function Documentation

bool kyototycoon::RPCClient::open ( const std::string &  host = "",
int32_t  port = DEFPORT,
double  timeout = -1 
)

Open the connection.

Parameters:
hostthe name or the address of the server. If it is an empty string, the local host is specified.
portthe port numger of the server.
timeoutthe timeout of each operation in seconds. If it is not more than 0, no timeout is specified.
Returns:
true on success, or false on failure.
bool kyototycoon::RPCClient::close ( bool  grace = true)

Close the connection.

Parameters:
gracetrue for graceful shutdown, or false for immediate disconnection.
Returns:
true on success, or false on failure.
ReturnValue kyototycoon::RPCClient::call ( const std::string &  name,
const std::map< std::string, std::string > *  inmap = NULL,
std::map< std::string, std::string > *  outmap = NULL 
)

Call a remote procedure.

Parameters:
namethe name of the procecude.
inmapa string map which contains the input of the procedure. If it is NULL, it is ignored.
outmapa string map to contain the output parameters. If it is NULL, it is ignored.
Returns:
the return value of the procedure.
const std::string kyototycoon::RPCClient::expression ( )

Get the expression of the socket.

Returns:
the expression of the socket or an empty string on failure.

Reveal the internal HTTP client.

Returns:
the internal HTTP client.