| Yang Gao | 75e2f6d | 2015-03-19 07:04:38 -0700 | [diff] [blame] | 1 | /* | 
 | 2 |  * | 
| Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 3 |  * Copyright 2015 gRPC authors. | 
| Yang Gao | 75e2f6d | 2015-03-19 07:04:38 -0700 | [diff] [blame] | 4 |  * | 
| Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 5 |  * Licensed under the Apache License, Version 2.0 (the "License"); | 
 | 6 |  * you may not use this file except in compliance with the License. | 
 | 7 |  * You may obtain a copy of the License at | 
| Yang Gao | 75e2f6d | 2015-03-19 07:04:38 -0700 | [diff] [blame] | 8 |  * | 
| Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 9 |  *     http://www.apache.org/licenses/LICENSE-2.0 | 
| Yang Gao | 75e2f6d | 2015-03-19 07:04:38 -0700 | [diff] [blame] | 10 |  * | 
| Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 11 |  * Unless required by applicable law or agreed to in writing, software | 
 | 12 |  * distributed under the License is distributed on an "AS IS" BASIS, | 
 | 13 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
 | 14 |  * See the License for the specific language governing permissions and | 
 | 15 |  * limitations under the License. | 
| Yang Gao | 75e2f6d | 2015-03-19 07:04:38 -0700 | [diff] [blame] | 16 |  * | 
 | 17 |  */ | 
 | 18 |  | 
| yang-g | 9e2f90c | 2015-08-21 15:35:03 -0700 | [diff] [blame] | 19 | #include <grpc++/generic/generic_stub.h> | 
| Yang Gao | 75e2f6d | 2015-03-19 07:04:38 -0700 | [diff] [blame] | 20 |  | 
 | 21 | #include <grpc++/impl/rpc_method.h> | 
 | 22 |  | 
 | 23 | namespace grpc { | 
 | 24 |  | 
| Vijay Pai | 4b047a3 | 2017-08-21 22:34:37 -0700 | [diff] [blame] | 25 | namespace { | 
 | 26 | std::unique_ptr<GenericClientAsyncReaderWriter> CallInternal( | 
 | 27 |     ChannelInterface* channel, ClientContext* context, | 
 | 28 |     const grpc::string& method, CompletionQueue* cq, bool start, void* tag) { | 
 | 29 |   return std::unique_ptr<GenericClientAsyncReaderWriter>( | 
| Vijay Pai | 7a64885 | 2017-10-27 10:22:51 -0700 | [diff] [blame] | 30 |       internal::ClientAsyncReaderWriterFactory<ByteBuffer, ByteBuffer>::Create( | 
| Craig Tiller | baa14a9 | 2017-11-03 09:09:36 -0700 | [diff] [blame] | 31 |           channel, cq, | 
 | 32 |           internal::RpcMethod(method.c_str(), | 
 | 33 |                               internal::RpcMethod::BIDI_STREAMING), | 
| Vijay Pai | 4b047a3 | 2017-08-21 22:34:37 -0700 | [diff] [blame] | 34 |           context, start, tag)); | 
 | 35 | } | 
 | 36 |  | 
 | 37 | }  // namespace | 
 | 38 |  | 
| Yang Gao | 75e2f6d | 2015-03-19 07:04:38 -0700 | [diff] [blame] | 39 | // begin a call to a named method | 
 | 40 | std::unique_ptr<GenericClientAsyncReaderWriter> GenericStub::Call( | 
| Craig Tiller | 277d3cf | 2015-04-14 14:04:51 -0700 | [diff] [blame] | 41 |     ClientContext* context, const grpc::string& method, CompletionQueue* cq, | 
 | 42 |     void* tag) { | 
| Vijay Pai | 4b047a3 | 2017-08-21 22:34:37 -0700 | [diff] [blame] | 43 |   return CallInternal(channel_.get(), context, method, cq, true, tag); | 
 | 44 | } | 
 | 45 |  | 
 | 46 | // setup a call to a named method | 
 | 47 | std::unique_ptr<GenericClientAsyncReaderWriter> GenericStub::PrepareCall( | 
 | 48 |     ClientContext* context, const grpc::string& method, CompletionQueue* cq) { | 
 | 49 |   return CallInternal(channel_.get(), context, method, cq, false, nullptr); | 
| Yang Gao | 75e2f6d | 2015-03-19 07:04:38 -0700 | [diff] [blame] | 50 | } | 
 | 51 |  | 
| Vijay Pai | 2046d0b | 2017-09-19 15:30:11 -0700 | [diff] [blame] | 52 | // setup a unary call to a named method | 
 | 53 | std::unique_ptr<GenericClientAsyncResponseReader> GenericStub::PrepareUnaryCall( | 
 | 54 |     ClientContext* context, const grpc::string& method, | 
 | 55 |     const ByteBuffer& request, CompletionQueue* cq) { | 
 | 56 |   return std::unique_ptr<GenericClientAsyncResponseReader>( | 
| Vijay Pai | 7a64885 | 2017-10-27 10:22:51 -0700 | [diff] [blame] | 57 |       internal::ClientAsyncResponseReaderFactory<ByteBuffer>::Create( | 
| Vijay Pai | 06e174a | 2017-10-20 05:51:12 -0700 | [diff] [blame] | 58 |           channel_.get(), cq, | 
 | 59 |           internal::RpcMethod(method.c_str(), internal::RpcMethod::NORMAL_RPC), | 
| Vijay Pai | 2046d0b | 2017-09-19 15:30:11 -0700 | [diff] [blame] | 60 |           context, request, false)); | 
 | 61 | } | 
 | 62 |  | 
| Craig Tiller | 277d3cf | 2015-04-14 14:04:51 -0700 | [diff] [blame] | 63 | }  // namespace grpc |