Factory.php
714 Bytes
<?php
namespace Hood\Utils\Rpc;
class Factory
{
private static $type = null;
/**
* 返回一个rpc
* @param $url
* @param string $type
* @return Httpc|Yar
*/
public static function getInstance($url, $type='yac')
{
if (strtolower($type) == 'yar') {
self::$type = 'yar';
return new Yar($url);
} else {
self::$type = 'yac';
return new Yac($url);
}
}
public static function loop($callback=null, $errorCallback=null)
{
if (self::$type == 'yar') {
Yar::loop($callback, $errorCallback);
} else {
Yac::loop($callback, $errorCallback);
}
}
}