| 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 | |
| 78 | private: |
| 79 | StreamReceiver _receiver; |
no test coverage detected