<?php require_once "../require.php"; //引入lib $path = TestAutoLoad::getFatherPath(dirname(__FILE__), 2) . '/lib'; //win \lib linux /lib TestAutoLoad::addRoot($path); TestAutoLoad::addRoot(dirname(dirname(__FILE__))); //异步使用client $client = new Swoole\Client\AsyncUdpClient(); $test = new TestCall(); $data = $test->initReqData(); $cmlbInfo = $test->getCmlbInfo(5910); if (!$cmlbInfo || !is_array($cmlbInfo)) { exit; } //回调函数 var_dump(" start time: " . microtime(true)); $client->send($cmlbInfo['host'], $cmlbInfo['port'], $data, array($test, 'call_back')); class TestCall { /** * [test 异步回包处理函数] * @param [type] $r [返回状态] * @param [type] $data [返回pb包数据] * @return [type] [description] */ public function call_back($r, $data) { var_dump(" finish time: " . microtime(true)); $spk_rspBody = new \Tencent\Crm\Spkey\RspBody();
/** * [setRoot 设置root根目录,可以同时添加多个] * @param array $root [array] */ public static function setRoot($rootArr = array()) { if (is_array($rootArr)) { self::$root_path = array_merge(self::$root_path, $rootArr); } }