首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Yar_Concurrent_Client::call

(PECL yar >= 1.0.0)

Yar_Concurrent_Client::call — Register a concurrent call

Description

代码语言:javascript
复制
public static int Yar_Concurrent_Client::call ( string $uri , string $method , array $parameters [, callable $callback ] )

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

Parameters

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.

Return Values

An unique id, can be used to identified which call it is.

Examples

Example #1 Yar_Concurrent_Client::call() example

代码语言:javascript
复制
<?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");
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",?NULL,?array(YAR_OPT_PACKAGER?=>?"json"));
???????????????????????????????????????????????????????????????????????????????//this?server?accept?json?packager
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
?>

The above example will output something similar to:

See Also

  • 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

← Yar_Concurrent_Client

Yar_Concurrent_Client::loop →

代码语言:txt
复制
 ? 1997–2017 The PHP Documentation Group

Licensed under the Creative Commons Attribution License v3.0 or later.

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com