<?php require 'vendor/autoload.php'; use zyzo\MeteorDDP\DDPClient; $client = new DDPClient('localhost', 3000); $client->connect(); function resultHandler($a) { $i = 10000000; while ($i--) { } echo 'Result = ' . $a . PHP_EOL; } $client->asyncCall("foo", array(1), 'resultHandler'); echo 'Doing some work..' . PHP_EOL; echo 'Doing some work..' . PHP_EOL; echo 'Doing some work..' . PHP_EOL; // anonymous function style $client->asyncCall("foo", array(1), function ($a) { resultHandler($a); }); echo 'Doing some work..' . PHP_EOL; echo 'Doing some work..' . PHP_EOL; echo 'Doing some work..' . PHP_EOL; $i = 100000000; while ($i--) { } $client->stop();
<?php namespace zyzo\MeteorDDP\tests; require 'vendor/autoload.php'; use zyzo\MeteorDDP\DDPClient; $client = new DDPClient('localhost', 3000); $client->connect(); $client->call("foo", array(1)); while (($yo = $client->getResult("foo")) === null) { sleep(1); } echo 'Result = ' . $yo . PHP_EOL; function resultHandler($a) { echo 'Result = ' . $a . PHP_EOL; } $client->asyncCall("foo", array(1), function ($a) { resultHandler($a); }); echo 'Do some work...' . PHP_EOL; $client->asyncCall("foo", array(1), 'zyzo\\MeteorDDP\\tests\\resultHandler'); echo 'Do some work...' . PHP_EOL; $client->stop();