Skip to content
Snippets Groups Projects
Commit 8c48a2a1 authored by Julien Boeuf's avatar Julien Boeuf
Browse files

Fixing cpp examples.

parent 3bb61d89
No related branches found
No related tags found
No related merge requests found
...@@ -245,7 +245,7 @@ To call service methods, we first need to create a *stub*. ...@@ -245,7 +245,7 @@ To call service methods, we first need to create a *stub*.
First we need to create a gRPC *channel* for our stub, specifying the server address and port we want to connect to without SSL: First we need to create a gRPC *channel* for our stub, specifying the server address and port we want to connect to without SSL:
```cpp ```cpp
grpc::CreateChannel("localhost:50051", grpc::InsecureCredentials()); grpc::CreateChannel("localhost:50051", grpc::InsecureChannelCredentials());
``` ```
Now we can use the channel to create our stub using the `NewStub` method provided in the `RouteGuide` class we generated from our .proto. Now we can use the channel to create our stub using the `NewStub` method provided in the `RouteGuide` class we generated from our .proto.
......
...@@ -94,7 +94,7 @@ $ protoc -I ../../protos/ --cpp_out=. ../../protos/helloworld.proto ...@@ -94,7 +94,7 @@ $ protoc -I ../../protos/ --cpp_out=. ../../protos/helloworld.proto
arguments as follows arguments as follows
``` ```
auto channel = CreateChannel("localhost:50051", InsecureCredentials()); auto channel = CreateChannel("localhost:50051", InsecureChannelCredentials());
``` ```
- Create a stub. A stub implements the rpc methods of a service and in the - Create a stub. A stub implements the rpc methods of a service and in the
......
...@@ -114,9 +114,9 @@ int main(int argc, char** argv) { ...@@ -114,9 +114,9 @@ int main(int argc, char** argv) {
// Instantiate the client. It requires a channel, out of which the actual RPCs // Instantiate the client. It requires a channel, out of which the actual RPCs
// are created. This channel models a connection to an endpoint (in this case, // are created. This channel models a connection to an endpoint (in this case,
// localhost at port 50051). We indicate that the channel isn't authenticated // localhost at port 50051). We indicate that the channel isn't authenticated
// (use of InsecureCredentials()). // (use of InsecureChannelCredentials()).
GreeterClient greeter( GreeterClient greeter(grpc::CreateChannel(
grpc::CreateChannel("localhost:50051", grpc::InsecureCredentials())); "localhost:50051", grpc::InsecureChannelCredentials()));
std::string user("world"); std::string user("world");
std::string reply = greeter.SayHello(user); // The actual RPC call! std::string reply = greeter.SayHello(user); // The actual RPC call!
std::cout << "Greeter received: " << reply << std::endl; std::cout << "Greeter received: " << reply << std::endl;
......
...@@ -84,9 +84,9 @@ int main(int argc, char** argv) { ...@@ -84,9 +84,9 @@ int main(int argc, char** argv) {
// Instantiate the client. It requires a channel, out of which the actual RPCs // Instantiate the client. It requires a channel, out of which the actual RPCs
// are created. This channel models a connection to an endpoint (in this case, // are created. This channel models a connection to an endpoint (in this case,
// localhost at port 50051). We indicate that the channel isn't authenticated // localhost at port 50051). We indicate that the channel isn't authenticated
// (use of InsecureCredentials()). // (use of InsecureChannelCredentials()).
GreeterClient greeter( GreeterClient greeter(grpc::CreateChannel(
grpc::CreateChannel("localhost:50051", grpc::InsecureCredentials())); "localhost:50051", grpc::InsecureChannelCredentials()));
std::string user("world"); std::string user("world");
std::string reply = greeter.SayHello(user); std::string reply = greeter.SayHello(user);
std::cout << "Greeter received: " << reply << std::endl; std::cout << "Greeter received: " << reply << std::endl;
......
...@@ -234,7 +234,8 @@ int main(int argc, char** argv) { ...@@ -234,7 +234,8 @@ int main(int argc, char** argv) {
// Expect only arg: --db_path=path/to/route_guide_db.json. // Expect only arg: --db_path=path/to/route_guide_db.json.
std::string db = routeguide::GetDbFileContent(argc, argv); std::string db = routeguide::GetDbFileContent(argc, argv);
RouteGuideClient guide( RouteGuideClient guide(
grpc::CreateChannel("localhost:50051", grpc::InsecureCredentials()), grpc::CreateChannel("localhost:50051",
grpc::InsecureChannelCredentials()),
db); db);
std::cout << "-------------- GetFeature --------------" << std::endl; std::cout << "-------------- GetFeature --------------" << std::endl;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment