Example #1
0
 /**
  * 首执行函数.
  *
  * return void.
  */
 public function init()
 {
     date_default_timezone_set("PRC");
     /* init Rpc client */
     TextRpcClient::config(Yii::app()->params['rpc']);
     /* to check access token expired. */
     // if ($this->isGetAccessToken) {
     //    $this->checkAccessToken();
     // }
     // $this->setInfo();
 }
Example #2
0
     */
    private function executionTime()
    {
        return microtime(true) - $this->executionTimeStart;
    }
}
spl_autoload_unregister(array('YiiBase', 'autoload'));
spl_autoload_register(function ($className) {
    if (strpos($className, 'RpcClient_') !== 0) {
        return false;
    }
    eval(sprintf('class %s extends TextRpcClient {}', $className));
});
spl_autoload_register(array('YiiBase', 'autoload'));
if (false) {
    $config = array('rpc_secret_key' => '769af463a39f077a0340a189e9c1ec28', 'User' => array('uri' => 'tcp://127.0.0.1:2201', 'user' => 'Optool', 'secret' => '{1BA09530-F9E6-478D-9965-7EB31A59537E}'), 'Item' => array('uri' => 'tcp://127.0.0.1:2201', 'user' => 'Optool', 'secret' => '{1BA09530-F9E6-478D-9965-7EB31A59537E}'), 'Order' => array('uri' => 'tcp://127.0.0.1:2201', 'user' => 'Optool', 'secret' => '{1BA09530-F9E6-478D-9965-7EB31A59537E}'));
    TextRpcClient::on('send', function ($data) {
        echo 'Send => ', $data, PHP_EOL;
    });
    TextRpcClient::on('recv', function ($data) {
        echo 'Recv <= ', $data, PHP_EOL;
    });
    TextRpcClient::config($config);
    //$test = RpcClient_Item_Iwc::instance();
    //var_export($test->getInventoryByWarehouses(array(100223,100002,100003,100006), array('BJ08','GZ07','SH05')));
    $test = RpcClient_User_Address::instance($config);
    //var_dump($test->getListByUid(5100));
    $test->getListByUid(5100, function () {
        var_dump(func_get_args());
    });
}