Register a concurrent call

# Yar_Concurrent_Client::call

(PECL yar >= 1.0.0)

Yar_Concurrent_Client::call — Register a concurrent call

### 説明

public static function Yar_Concurrent_Client::call(
string `$uri`,
string `$method`,
array `$parameters` = ?,
callable `$callback` = ?,
callable `$error_callback` = ?,
array `$options` = ?
): int

Register a RPC call, but won't sent it immediately, it will be send while further call to Yar_Concurrent_Client::loop().

### パラメータ

`uri`

  The RPC server URI (HTTP, TCP).

`method`

  Service name (aka the method name).

`parameters`

  Parameters.

`callback`

  A function callback, which will be called while the response return.

`error_callback`
  If this callback is set, then Yar will call this callback while error occurred.
`options`
  An array of options. See the constants list.

### 戻り値

A unique ID, can be used to identified which call it is.

### 例

    <?php

    function callback($retval, $callinfo)
    {
        var_dump($retval);
    }

    function error_callback($type, $error, $callinfo)
    {
        error_log($error);
    }

    Yar_Concurrent_Client::call("http://host/api/", "some_method", array("parameters"), "callback");

    // If the callback is not specified callback in loop will be used
    Yar_Concurrent_Client::call("http://host/api/", "some_method", array("parameters"));

    // This server accept JSON packager
    Yar_Concurrent_Client::call("http://host/api/", "some_method", array("parameters"), "callback", NULL, array(YAR_OPT_PACKAGER => "json"));

    // Custom timeout
    Yar_Concurrent_Client::call("http://host/api/", "some_method", array("parameters"), "callback", NULL, array(YAR_OPT_TIMEOUT => 1));

    // The requests are not sent yet

上の例の出力は、 たとえば以下のようになります。

### 参考

- Yar_Concurrent_Client::loop() - Send all calls
- Yar_Concurrent_Client::reset() - Clean all registered calls
- Yar_Server::__construct() - Register a server
- Yar_Server::handle() - Start RPC Server

`↑` and `↓` to navigate • `Enter` to select • `Esc` to close • `/` to open