public function excute() { $tcpCli = \Aha\Client\Pool::getUdpClient('10.10.8.172', '9603'); $tcpCli->setRequestId('UdpRequest'); $tcpCli->setCallback(array($this, 'output')); $arrDara = array('cmd' => 'demo-server-udp', 'body' => 'from http request'); $tcpCli->setPackage(json_encode($arrDara)); $tcpCli->loop(); }
public function getFromMulti() { $http1 = \Aha\Client\Pool::getHttpClient('GET', 'http://www.qq.com/'); $http1->setRequestId('trunked'); $http2 = \Aha\Client\Pool::getHttpClient('GET', 'http://www.jd.com/'); $http2->setRequestId('length'); $mutli = new \Aha\Client\Multi(); $mutli->register($http1); $ret = (yield $mutli->register($http2)); (yield $ret); }
public function excute() { // $http1 = \Aha\Client\Pool::getHttpClient('GET', 'http://www.qq.com/'); // $http1->setRequestId('trunked'); // $http2 = \Aha\Client\Pool::getHttpClient('GET', 'http://www.jd.com/'); // $http2->setRequestId('length'); // $mutli = new Multi(); // $mutli->register($http1); // $mutli->register($http2); // $mutli->loop(array($this,'output')); $http = \Aha\Client\Pool::getHttpClient('GET', 'http://www.jd.com/'); $http->setRequestId('contentLength'); $http->setCallback(array($this, 'output')); $http->loop(); }
/** * @brief 发生错误的时候 吧连接放回gc 出发close事件可能会gc重复 但是无所谓 * @param \swoole_client $client */ public function onError(\swoole_client $client) { parent::onError($client); $poolName = $this->_host . ':' . $this->_port; \Aha\Client\Pool::gcTcp($poolName, $this); }