Esempio n. 1
0
        var_dump((yield $test->hello("yield world2")));
        var_dump((yield $test->hello("yield world3")));
        var_dump((yield $test->hello("yield world4")));
        var_dump((yield $test->hello("yield world5")));
        var_dump((yield $test->hello("yield world6")));
    } catch (\Exception $e) {
        echo $e;
    }
});
$var_dump($test->hello("async world1"));
$var_dump($test->hello("async world2"));
$var_dump($test->hello("async world3"));
$var_dump($test->hello("async world4"));
$var_dump($test->hello("async world5"));
$var_dump($test->hello("async world6"));
$test->sum(1, 2)->then(function ($result) use($test) {
    var_dump($result);
    return $test->sum($result, 1);
})->then(function ($result) use($test) {
    var_dump($result);
    return $test->sum($result, 1);
})->then(function ($result) use($test) {
    var_dump($result);
    return $test->sum($result, 1);
})->then(function ($result) use($test) {
    var_dump($result);
    return $test->sum($result, 1);
})->then(function ($result) use($test) {
    var_dump($result);
    return $test->sum($result, 1);
})->then(function ($result) {
Esempio n. 2
0
<?php

require_once "../../vendor/autoload.php";
use Hprose\Socket\Client;
use Hprose\InvokeSettings;
$test = new Client("tcp://127.0.0.1:1315");
$test->fullDuplex = true;
$test->timeout = 600;
$test->sum(1, 2)->catchError(function ($e) {
    //echo $e;
});
$test->sum(1, 2)->then(function ($result) {
    echo "1 + 2 = " . $result;
})->catchError(function ($e) use($test) {
    //echo $e;
    $test->sum(2, 3, new InvokeSettings(array('timeout' => 20000)))->then(function ($result) {
        echo "2 + 3 = " . $result;
    })->catchError(function ($e) {
        echo $e;
    });
});
$test->loop();