blob: f352573f34a4c0f30c8ef703b112a52798a7a01d [file] [log] [blame]
mlumish156e67d2015-01-02 14:59:16 -08001<?php
2namespace Grpc;
3
4require_once realpath(dirname(__FILE__) . '/../autoload.php');
5
6/**
7 * Represents an active call that sends a single message and then gets a single
8 * response.
9 */
10class SimpleSurfaceActiveCall extends AbstractSurfaceActiveCall {
11 /**
12 * Create a new simple (single request/single response) active call.
13 * @param Channel $channel The channel to communicate on
14 * @param string $method The method to call on the remote server
15 * @param callable $deserialize The function to deserialize a value
16 * @param $arg The argument to send
17 * @param array $metadata Metadata to send with the call, if applicable
18 */
19 public function __construct(Channel $channel,
20 $method,
21 callable $deserialize,
22 $arg,
23 $metadata = array()) {
24 parent::__construct($channel, $method, $deserialize, $metadata,
25 \Grpc\WRITE_BUFFER_HINT);
26 $this->_write($arg);
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}