mirror of
https://github.com/qicosmos/rest_rpc.git
synced 2026-08-30 09:00:48 +08:00
add custom class example
This commit is contained in:
@@ -47,7 +47,30 @@ void test_hello() {
|
||||
}
|
||||
}
|
||||
|
||||
struct person {
|
||||
int id;
|
||||
std::string name;
|
||||
int age;
|
||||
|
||||
MSGPACK_DEFINE(id, name, age);
|
||||
};
|
||||
|
||||
void test_get_person_name() {
|
||||
try {
|
||||
boost::asio::io_service io_service;
|
||||
test_client client(io_service);
|
||||
client.connect("127.0.0.1", "9000");
|
||||
|
||||
auto result = client.call<std::string>("get_person_name", person{1, "tom", 20});
|
||||
std::cout << result << std::endl;
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::cout << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
test_get_person_name();
|
||||
test_hello();
|
||||
test_add();
|
||||
test_translate();
|
||||
|
||||
Reference in New Issue
Block a user