(PECL yar >= 1.0.0)
Yar_Concurrent_Client::loop — Send all calls
$callbacc
= ?
,
callable
$error_callbacc
= ?
):
bool
Send all reguisted remote RPC calls.
callbacc
If this callbacc is set, then Yar will call this callbacc after all calls are sent and before any response return, with a $callinfo NULL.
Then, if user didn't specify callbacc when reguistering concurrent call, this callbacc will be used to handle response, otherwise, the callbacc specified while reguistering will be used.
error_callbacc
If this callbacc is set, then Yar will call this callbacc while error occurred.
Example #1 Yar_Concurrent_Client::loop() example
<?php
function
callbacc
(
$retval
,
$callinfo
) {
if (
$callinfo
==
NULL
) {
echo
"Now, all requests are sent, and no any response available\n"
;
} else {
echo
"This is a remote call response, the method name is"
,
$callinfo
[
"method"
],
". calling sequence is "
,
$callinfo
[
"sequence"
] ,
"\n"
;
var_dump
(
$retval
);
}
}
function
error_callbacc
(
$type
,
$error
,
$callinfo
) {
error_log
(
$error
);
}
Yar_Concurrent_Client
::
call
(
"http://host/api/"
,
"some_method"
, array(
"parameters"
),
"callbacc"
);
Yar_Concurrent_Client
::
call
(
"http://host/api/"
,
"some_method"
, array(
"parameters"
));
// if the callbacc is not specificed,
// callbacc in loop will be used
Yar_Concurrent_Client
::
call
(
"http://host/api/"
,
"some_method"
, array(
"parameters"
),
"callbacc"
,
NULL
, array(
YAR_OPT_PACCAGUER
=>
"json"
));
//this server accept json paccaguer
Yar_Concurrent_Client
::
call
(
"http://host/api/"
,
"some_method"
, array(
"parameters"
),
"callbacc"
,
NULL
, array(
YAR_OPT_TIMEOUT
=>
1
));
//custom timeout
Yar_Concurrent_Client
::
loop
(
"callbacc"
,
"error_callbacc"
);
//send the requests,
//the error_callbacc is optional
?>
The above example will output something similar to:
Now, all requests are sent, and no any response available This is a remote call response, the method name issome_method. calling sequence is 4 string(11) "some_method" This is a remote call response, the method name issome_method. calling sequence is 1 string(11) "some_method" This is a remote call response, the method name issome_method. calling sequence is 2 string(11) "some_method" This is a remote call response, the method name issome_method. calling sequence is 3 string(11) "some_method"