diff options
Diffstat (limited to 'src/php/lib/Grpc/BidiStreamingCall.php')
-rw-r--r-- | src/php/lib/Grpc/BidiStreamingCall.php | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/php/lib/Grpc/BidiStreamingCall.php b/src/php/lib/Grpc/BidiStreamingCall.php index 454f7621ae..2afceafce9 100644 --- a/src/php/lib/Grpc/BidiStreamingCall.php +++ b/src/php/lib/Grpc/BidiStreamingCall.php @@ -43,10 +43,7 @@ class BidiStreamingCall extends AbstractCall { * @param array $metadata Metadata to send with the call, if applicable */ public function start($metadata) { - $event = $this->call->start_batch([ - OP_SEND_INITIAL_METADATA => $metadata, - OP_RECV_INITIAL_METADATA => true]); - $this->metadata = $event->metadata; + $this->call->start_batch([OP_SEND_INITIAL_METADATA => $metadata]); } /** @@ -54,7 +51,14 @@ class BidiStreamingCall extends AbstractCall { * @return The next value from the server, or null if there is none */ public function read() { - $read_event = $this->call->start_batch([OP_RECV_MESSAGE => true]); + $batch = [OP_RECV_MESSAGE => true]; + if ($this->metadata === null) { + $batch[OP_RECV_INITIAL_METADATA] = true; + } + $read_event = $this->call->start_batch($batch); + if ($this->metadata === null) { + $this->metadata = $read_event->metadata; + } return $this->deserializeResponse($read_event->message); } |