blob: fa643e50a8eb0c32b1e987c44430ede758b5eaf2 [file] [log] [blame]
mlumish156e67d2015-01-02 14:59:16 -08001<?php
2namespace Grpc;
3require_once realpath(dirname(__FILE__) . '/../autoload.php');
4
5/**
6 * Represents an active call that sends a stream of messages and then gets a
7 * single response.
8 */
9class ClientStreamingSurfaceActiveCall extends AbstractSurfaceActiveCall {
10 /**
11 * Create a new simple (single request/single response) active call.
12 * @param Channel $channel The channel to communicate on
13 * @param string $method The method to call on the remote server
14 * @param callable $deserialize The function to deserialize a value
15 * @param Traversable $arg_iter The iterator of arguments to send
16 * @param array $metadata Metadata to send with the call, if applicable
17 */
18 public function __construct(Channel $channel,
19 $method,
20 callable $deserialize,
21 $arg_iter,
22 $metadata = array()) {
23 parent::__construct($channel, $method, $deserialize, $metadata, 0);
24 foreach($arg_iter as $arg) {
25 $this->_write($arg);
26 }
27 $this->_writesDone();
28 }
29
30 /**
31 * Wait for the server to respond with data and a status
32 * @return [response data, status]
33 */
34 public function wait() {
35 $response = $this->_read();
36 $status = $this->_getStatus();
37 return array($response, $status);
38 }
39}