-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathClient.cpp
31 lines (22 loc) · 891 Bytes
/
Client.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "SimpleRpcChannel.h"
#include "SimpleRpc.pb.h"
#include <iostream>
#include "args.hxx"
int main(int argc, char* argv[]) {
args::ArgumentParser parser("SimpleRpc argument");
args::ValueFlag<std::string> addr(parser, "ip addr", "ip address", {'i'},
"tcp://127.0.0.1:1234");
parser.ParseCLI(argc, argv);
std::string ip_addr = args::get(addr);
srpc::SimpleRpcChannel channel(ip_addr.c_str());
SimpleRpc::SimpleService_Stub stub(&channel);
SimpleRpc::SimpleRequest request;
request.set_request("My first request.");
SimpleRpc::SimpleResponse response;
stub.SimpleCall(nullptr, &request, &response, nullptr);
std::cout << response.response() << std::endl;
request.set_request("My second request.");
stub.SimpleCall(nullptr, &request, &response, nullptr);
std::cout << response.response() << std::endl;
return 0;
}