Пример #1
0
 /**
  * @brief 初始化一个tcp客户端
  * @param  $host
  * @param  $port
  * @param type $timeout
  * @param type $connectTimeout
  */
 public function __construct($host, $port, $timeout = 1, $connectTimeout = 0.05)
 {
     //开启长连接默认用IP:PORT作为key
     $client = new \swoole_client(SWOOLE_SOCK_TCP, SWOOLE_SOCK_ASYNC);
     parent::__construct($client, $host, $port, $timeout, $connectTimeout);
     $this->_initConfig();
 }
Пример #2
0
Файл: Http.php Проект: vucms/aha
 /**
  * @brief 初始化一个http客户端
  * @param  $method
  * @param  $url
  * @param type $timeout
  * @param type $connectTimeout
  */
 public function __construct($method, $url, $timeout = 1, $connectTimeout = 0.05)
 {
     if (!in_array($method, array('GET', 'POST'))) {
         throw new Exception("unsupport http method {$method}");
     }
     $this->_method = $method;
     $this->_url = $url;
     $client = new \swoole_client(SWOOLE_SOCK_TCP, SWOOLE_SOCK_ASYNC);
     parent::__construct($client, $this->_host, $this->_port, $timeout, $connectTimeout);
     $this->_initConfig();
 }
Пример #3
0
 /**
  * @brief 实例化redis client
  * @param type $conf
  * @return \Aha\Storage\Memory\Rediscli
  */
 public function __construct($conf)
 {
     $host = $conf['host'];
     $port = $conf['port'];
     $timeout = $conf['timeout'];
     //TODO |SWOOLE_KEEP
     $client = new \swoole_client(SWOOLE_SOCK_TCP, SWOOLE_SOCK_ASYNC);
     parent::__construct($client, $host, $port, $timeout);
     $this->_initConfig();
     return $this;
 }
Пример #4
0
 /**
  * @brief 初始化一个http客户端
  * @param  $method
  * @param  $url
  * @param type $timeout
  * @param type $connectTimeout
  */
 public function __construct($method, $url, $timeout = 1, $connectTimeout = 0.05)
 {
     if (!in_array($method, array('GET', 'POST'))) {
         throw new Exception("unsupport http method {$method}");
     }
     $this->_method = $method;
     $this->_url = $url;
     $sockType = SWOOLE_SOCK_TCP;
     $scheme = parse_url($url, PHP_URL_SCHEME);
     if ($scheme == 'https') {
         $sockType |= SWOOLE_SSL;
     }
     $client = new \swoole_client($sockType, SWOOLE_SOCK_ASYNC);
     parent::__construct($client, $this->_host, $this->_port, $timeout, $connectTimeout);
     $this->_initConfig();
 }