MCPcopy Create free account
hub / github.com/apache/brpc / Echo

Method Echo

example/streaming_echo_c++/server.cpp:59–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57 brpc::StreamClose(_sd);
58 };
59 virtual void Echo(google::protobuf::RpcController* controller,
60 const example::EchoRequest* /*request*/,
61 example::EchoResponse* response,
62 google::protobuf::Closure* done) {
63 // This object helps you to call done->Run() in RAII style. If you need
64 // to process the request asynchronously, pass done_guard.release().
65 brpc::ClosureGuard done_guard(done);
66
67 brpc::Controller* cntl =
68 static_cast<brpc::Controller*>(controller);
69 brpc::StreamOptions stream_options;
70 stream_options.handler = &_receiver;
71 if (brpc::StreamAccept(&_sd, *cntl, &stream_options) != 0) {
72 cntl->SetFailed("Fail to accept stream");
73 return;
74 }
75 response->set_message("Accepted stream");
76 }
77
78private:
79 StreamReceiver _receiver;

Callers 1

mainFunction · 0.45

Calls 2

StreamAcceptFunction · 0.85
SetFailedMethod · 0.45

Tested by

no test coverage detected