diff options
author | 2015-02-11 23:43:20 -0800 | |
---|---|---|
committer | 2015-02-11 23:43:20 -0800 | |
commit | b492f06c9dc45c62f1cb46b9320a25f0f4be4300 (patch) | |
tree | 7cedd1cc0b2579d037f7cbaaed6f1701cf5c1238 /include | |
parent | fd7199f64ec05c46f6aebd8644bbcb78f2889898 (diff) |
Add SendInitialMetadata() to server streaming interfaces
Diffstat (limited to 'include')
-rw-r--r-- | include/grpc++/stream.h | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/include/grpc++/stream.h b/include/grpc++/stream.h index 6da1be4e9f..be518c61ed 100644 --- a/include/grpc++/stream.h +++ b/include/grpc++/stream.h @@ -111,7 +111,6 @@ class ClientReader final : public ClientStreamingInterface, } } - virtual bool Read(R *msg) override { WaitForInitialMetadata(); CallOpBuffer buf; @@ -255,7 +254,14 @@ class ClientReaderWriter final : public ClientStreamingInterface, template <class R> class ServerReader final : public ReaderInterface<R> { public: - explicit ServerReader(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} + ServerReader(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} + + void SendInitialMetadata() { + CallOpBuffer buf; + ctx_->SendInitialMetadataIfNeeded(&buf); + call_->PerformOps(&buf); + return call_->cq()->Pluck(&buf); + } virtual bool Read(R* msg) override { CallOpBuffer buf; @@ -273,7 +279,14 @@ class ServerReader final : public ReaderInterface<R> { template <class W> class ServerWriter final : public WriterInterface<W> { public: - explicit ServerWriter(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} + ServerWriter(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} + + void SendInitialMetadata() { + CallOpBuffer buf; + ctx_->SendInitialMetadataIfNeeded(&buf); + call_->PerformOps(&buf); + return call_->cq()->Pluck(&buf); + } virtual bool Write(const W& msg) override { CallOpBuffer buf; @@ -293,7 +306,14 @@ template <class W, class R> class ServerReaderWriter final : public WriterInterface<W>, public ReaderInterface<R> { public: - explicit ServerReaderWriter(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} + ServerReaderWriter(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} + + void SendInitialMetadata() { + CallOpBuffer buf; + ctx_->SendInitialMetadataIfNeeded(&buf); + call_->PerformOps(&buf); + return call_->cq()->Pluck(&buf); + } virtual bool Read(R* msg) override { CallOpBuffer buf; |