Exemple #1
0
 /**
  * Create a new Call wrapper object.
  * @param Channel $channel The channel to communicate on
  * @param string $method The method to call on the remote server
  * @param callback $deserialize A callback function to deserialize
  * the response
  * @param (optional) long $timeout Timeout in microseconds
  */
 public function __construct(Channel $channel, $method, $deserialize, $timeout = false)
 {
     if ($timeout) {
         $now = Timeval::now();
         $delta = new Timeval($timeout);
         $deadline = $now->add($delta);
     } else {
         $deadline = Timeval::infFuture();
     }
     $this->call = new Call($channel, $method, $deadline);
     $this->deserialize = $deserialize;
     $this->metadata = null;
 }
Exemple #2
0
 /**
  * Create a new Call wrapper object.
  *
  * @param Channel  $channel     The channel to communicate on
  * @param string   $method      The method to call on the
  *                              remote server
  * @param callback $deserialize A callback function to deserialize
  *                              the response
  * @param array    $options     Call options (optional)
  */
 public function __construct(Channel $channel, $method, $deserialize, $options = [])
 {
     if (isset($options['timeout']) && is_numeric($timeout = $options['timeout'])) {
         $now = Timeval::now();
         $delta = new Timeval($timeout);
         $deadline = $now->add($delta);
     } else {
         $deadline = Timeval::infFuture();
     }
     $this->call = new Call($channel, $method, $deadline);
     $this->deserialize = $deserialize;
     $this->metadata = null;
     if (isset($options['call_credentials_callback']) && is_callable($call_credentials_callback = $options['call_credentials_callback'])) {
         $call_credentials = CallCredentials::createFromPlugin($call_credentials_callback);
         $this->call->setCredentials($call_credentials);
     }
 }
Exemple #3
0
 /**
  * Create a new Call wrapper object.
  * @param Channel $channel The channel to communicate on
  * @param string $method The method to call on the remote server
  */
 public function __construct(Channel $channel, $method, $deserialize)
 {
     $this->call = new Call($channel, $method, Timeval::infFuture());
     $this->deserialize = $deserialize;
     $this->metadata = null;
 }