(PECL yar >= 1.0.0)
Yar_Concurrent_Client::call — Register a concurrent call
$uri,$method,$parameters = ?,$callback = ?,$error_callback = ?,$options = ?Register a RPC call, but won't sent it immediately, it will be send while further call to Yar_Concurrent_Client::loop().
uriThe RPC server URI (HTTP, TCP).
methodService name (aka the method name).
parametersParameters.
callbackA function callback, which will be called while the response return.
error_callbackoptionsA 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上の例の出力は、 たとえば以下のようになります。