@@ -45,11 +45,11 @@ using namespace tbox;
4545
4646int main (int argc, char **argv)
4747{
48- jsonrpc::Rpc:: IdType id_type = jsonrpc::Rpc ::IdType::kInt ;
48+ jsonrpc::IdType id_type = jsonrpc::IdType::kInt ;
4949 if (argc >= 2 ) {
5050 std::string type_str (argv[1 ]);
5151 if (type_str == " str" ) {
52- id_type = jsonrpc::Rpc:: IdType::kString ;
52+ id_type = jsonrpc::IdType::kString ;
5353 } else if (type_str != " int" ) {
5454 std::cout << " id_type invalid!" << std::endl
5555 << " Usage: " << argv[0 ] << " int|str" << std::endl;
@@ -111,14 +111,15 @@ int main(int argc, char **argv)
111111
112112 // ! 发送ping请求,并在收到回复后,进行下一个ping动作
113113 rpc.request (" ping" , js_params,
114- [&] (int errcode, const Json &js_result ) {
115- int pong_count = 0 ;
116- util::json::GetField (js_result, " count " , pong_count) ;
117- if (errcode == 0 ) {
114+ [&] (const tbox::jsonrpc::Response &r ) {
115+ if (r. error . code == 0 ) {
116+ int pong_count = 0 ;
117+ util::json::GetField (r. js_result , " count " , pong_count);
118118 LogDbg (" got pong: %d" , pong_count);
119119 send_ping ();
120- } else
121- LogNotice (" got erro: %d" , errcode);
120+ } else {
121+ LogNotice (" got erro: %d" , r.error .code );
122+ }
122123 });
123124 LogDbg (" send ping: %d" , ping_count);
124125 };
0 commit comments