Ejemplo n.º 1
0
<?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();
Ejemplo n.º 2
0
<?php

/**
 * @Author: winterswang
 * @Date:   2015-02-28 12:18:52
 * @Last Modified by:   winterswang
 * @Last Modified time: 2015-03-24 11:35:36
 */
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 = array('cmd' => 2, 'seq' => 1);
$client->send('10.213.168.89', 9501, serialize($data), array($test, 'call_back'));
// $client ->send('127.0.0.1',9905,'async',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(unserialize($data));
Ejemplo n.º 3
0
<?php

/**
 * @Author: winterswang
 * @Date:   2015-02-28 12:18:52
 * @Last Modified by:   winterswang
 * @Last Modified time: 2015-03-11 21:13:50
 */
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 = array('cmd' => 4, 'seq' => 1);
$client->send('10.130.73.229', 9501, serialize($data), array($test, 'call_back'));
// $client ->send('127.0.0.1',9905,'async',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(unserialize($data));
Ejemplo n.º 4
0
<?php

/**
 * @Author: winterswang
 * @Date:   2015-02-04 16:51:59
 * @Last Modified by:   winterswang
 * @Last Modified time: 2015-02-04 17:28:37
 */
require_once "../require.php";
require "../data/PhoneAttriInterface_wup.php";
$path = TestAutoLoad::getFatherPath(dirname(__FILE__), 2) . '/lib';
//win \lib linux /lib
TestAutoLoad::addRoot($path);
TestAutoLoad::addRoot(dirname(dirname(__FILE__)));
$client = new Swoole\Client\AsyncUdpClient();
$test = new TestCall();
$data = $test->initReqData();
$client->send('10.231.138.154', 12652, $data, array($test, 'call_back'));
class TestCall
{
    /**
     * [call_back description]
     * @param  [type] $r    [description]
     * @param  [type] $data [respBuffer]
     * @return [type]       [description]
     */
    public function call_back($r, $data)
    {
        $wupResp = new wup_unipacket();
        $wupResp->setVersion(3);
        $wupResp->_decode($data);