Update example

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@332245 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Xinchen Hui 2013-12-03 08:03:54 +00:00
parent 211d74668b
commit 26fa02c469
3 changed files with 23 additions and 6 deletions

View file

@ -85,10 +85,12 @@ function error_callback($type, $error, $callinfo) {
Yar_Concurrent_Client::call("http://host/api/", "some_method", array("parameters"), "callback");
Yar_Concurrent_Client::call("http://host/api/", "some_method", array("parameters")); // if the callback is not specificed,
// callback in loop will be used
Yar_Concurrent_Client::call("http://host/api/", "some_method", array("parameters"), "callback", array(YAR_OPT_PACKAGER => "json"));
Yar_Concurrent_Client::call("http://host/api/", "some_method", array("parameters"), "callback", NULL, array(YAR_OPT_PACKAGER => "json"));
//this server accept json packager
Yar_Concurrent_Client::call("http://host/api/", "some_method", array("parameters"), "callback", array(YAR_OPT_TIMEOUT=>1));
Yar_Concurrent_Client::call("http://host/api/", "some_method", array("parameters"), "callback", NULL, array(YAR_OPT_TIMEOUT=>1));
//custom timeout
//The requests are not sent yet
?>
]]>
</programlisting>
@ -105,6 +107,8 @@ Yar_Concurrent_Client::call("http://host/api/", "some_method", array("parameters
&reftitle.seealso;
<simplelist>
<member><methodname>Yar_Concurrent_Client::loop</methodname></member>
<member><methodname>Yar_Server::__construct</methodname></member>
<member><methodname>Yar_Server::handle</methodname></member>
</simplelist>
</refsect1>

View file

@ -64,9 +64,10 @@
<?php
function callback($retval, $callinfo) {
if ($callinfo == NULL) {
echo "Now, all requests are sent, and no any response available";
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"];
echo "This is a remote call response, the method name is", $callinfo["method"],
". calling sequence is " , $callinfo["sequence"] , "\n";
var_dump($retval);
}
}
@ -78,9 +79,9 @@ function error_callback($type, $error, $callinfo) {
Yar_Concurrent_Client::call("http://host/api/", "some_method", array("parameters"), "callback");
Yar_Concurrent_Client::call("http://host/api/", "some_method", array("parameters")); // if the callback is not specificed,
// callback in loop will be used
Yar_Concurrent_Client::call("http://host/api/", "some_method", array("parameters"), "callback", array(YAR_OPT_PACKAGER => "json"));
Yar_Concurrent_Client::call("http://host/api/", "some_method", array("parameters"), "callback", NULL, array(YAR_OPT_PACKAGER => "json"));
//this server accept json packager
Yar_Concurrent_Client::call("http://host/api/", "some_method", array("parameters"), "callback", array(YAR_OPT_TIMEOUT=>1));
Yar_Concurrent_Client::call("http://host/api/", "some_method", array("parameters"), "callback", NULL, array(YAR_OPT_TIMEOUT=>1));
//custom timeout
Yar_Concurrent_Client::loop("callback", "error_callback"); //send the requests,
@ -91,6 +92,15 @@ Yar_Concurrent_Client::loop("callback", "error_callback"); //send the requests,
&example.outputs.similar;
<screen>
<![CDATA[
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"
]]>
</screen>
</example>
@ -101,6 +111,8 @@ Yar_Concurrent_Client::loop("callback", "error_callback"); //send the requests,
&reftitle.seealso;
<simplelist>
<member><methodname>Yar_Concurrent_Client::call</methodname></member>
<member><methodname>Yar_Server::__construct</methodname></member>
<member><methodname>Yar_Server::handle</methodname></member>
</simplelist>
</refsect1>

View file

@ -55,6 +55,7 @@ class API {
* @return
*/
public function some_method($parameter, $option = "foo") {
return "some_method";
}
protected function client_can_not_see() {