Kyoto Tycoon

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

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.
HTTPClient * | reveal_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

enum kyototycoon::RPCClient::ReturnValue

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

kyototycoon::RPCClient::RPCClient | ( |  | ) |

Default constructor.

kyototycoon::RPCClient::~RPCClient | ( |  | ) |

Destructor.

## Member Function Documentation

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

Open the connection.

Parameters:

  host | the name or the address of the server. If it is an empty string, the local host is specified.
  port | the port numger of the server.
  timeout | the 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:

  grace | true 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:

  name | the name of the procecude.
  inmap | a string map which contains the input of the procedure. If it is NULL, it is ignored.
  outmap | a 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.

HTTPClient* kyototycoon::RPCClient::reveal_core | ( |  | ) |

Reveal the internal HTTP client.

Returns:
  the internal HTTP client.