Merge pull request #55 from yang-g/channel

CreateChannel API change syncup and regenerate files
pull/3109/head
Craig Tiller 10 years ago
commit 0a6ed67c66
  1. 2
      cpp/helloworld/greeter_client.cc
  2. 5
      cpp/helloworld/greeter_server.cc
  3. 8
      cpp/helloworld/helloworld.pb.cc
  4. 4
      cpp/helloworld/helloworld.pb.h

@ -80,7 +80,7 @@ int main(int argc, char** argv) {
grpc_init(); grpc_init();
GreeterClient greeter( GreeterClient greeter(
grpc::CreateChannel("localhost:50051", ChannelArguments())); grpc::CreateChannelDeprecated("localhost:50051", ChannelArguments()));
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;

@ -34,7 +34,6 @@
#include <iostream> #include <iostream>
#include <memory> #include <memory>
#include <string> #include <string>
#include <thread>
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc++/server.h> #include <grpc++/server.h>
@ -69,9 +68,7 @@ void RunServer() {
builder.RegisterService(&service); builder.RegisterService(&service);
std::unique_ptr<Server> server(builder.BuildAndStart()); std::unique_ptr<Server> server(builder.BuildAndStart());
std::cout << "Server listening on " << server_address << std::endl; std::cout << "Server listening on " << server_address << std::endl;
while (true) { server->Wait();
std::this_thread::sleep_for(std::chrono::seconds(5));
}
} }
int main(int argc, char** argv) { int main(int argc, char** argv) {

@ -590,8 +590,8 @@ static const char* Greeter_method_names[] = {
"/helloworld.Greeter/SayHello", "/helloworld.Greeter/SayHello",
}; };
Greeter::Stub* Greeter::NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel) { std::unique_ptr< Greeter::Stub> Greeter::NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel) {
Greeter::Stub* stub = new Greeter::Stub(); std::unique_ptr< Greeter::Stub> stub(new Greeter::Stub());
stub->set_channel(channel); stub->set_channel(channel);
return stub; return stub;
}; };
@ -600,8 +600,8 @@ Greeter::Stub* Greeter::NewStub(const std::shared_ptr< ::grpc::ChannelInterface>
return ::grpc::BlockingUnaryCall(channel(),::grpc::RpcMethod(Greeter_method_names[0]), context, request, response); return ::grpc::BlockingUnaryCall(channel(),::grpc::RpcMethod(Greeter_method_names[0]), context, request, response);
} }
::grpc::ClientAsyncResponseReader< ::helloworld::HelloReply>* Greeter::Stub::SayHello(::grpc::ClientContext* context, const ::helloworld::HelloRequest& request, ::grpc::CompletionQueue* cq, void* tag) { std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::helloworld::HelloReply>> Greeter::Stub::SayHello(::grpc::ClientContext* context, const ::helloworld::HelloRequest& request, ::grpc::CompletionQueue* cq, void* tag) {
return new ::grpc::ClientAsyncResponseReader< ::helloworld::HelloReply>(channel(), cq, ::grpc::RpcMethod(Greeter_method_names[0]), context, request, tag); return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::helloworld::HelloReply>>(new ::grpc::ClientAsyncResponseReader< ::helloworld::HelloReply>(channel(), cq, ::grpc::RpcMethod(Greeter_method_names[0]), context, request, tag));
} }
Greeter::AsyncService::AsyncService(::grpc::CompletionQueue* cq) : ::grpc::AsynchronousService(cq, Greeter_method_names, 1) {} Greeter::AsyncService::AsyncService(::grpc::CompletionQueue* cq) : ::grpc::AsynchronousService(cq, Greeter_method_names, 1) {}

@ -320,9 +320,9 @@ class Greeter final {
class Stub final : public ::grpc::InternalStub { class Stub final : public ::grpc::InternalStub {
public: public:
::grpc::Status SayHello(::grpc::ClientContext* context, const ::helloworld::HelloRequest& request, ::helloworld::HelloReply* response); ::grpc::Status SayHello(::grpc::ClientContext* context, const ::helloworld::HelloRequest& request, ::helloworld::HelloReply* response);
::grpc::ClientAsyncResponseReader< ::helloworld::HelloReply>* SayHello(::grpc::ClientContext* context, const ::helloworld::HelloRequest& request, ::grpc::CompletionQueue* cq, void* tag); std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::helloworld::HelloReply>> SayHello(::grpc::ClientContext* context, const ::helloworld::HelloRequest& request, ::grpc::CompletionQueue* cq, void* tag);
}; };
static Stub* NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel); static std::unique_ptr<Stub> NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel);
class Service : public ::grpc::SynchronousService { class Service : public ::grpc::SynchronousService {
public: public:

Loading…
Cancel
Save