/** * Constructor. * @return void */ public function init() { $req = $this; $job = $this->job = new ComplexJob(function () use($req) { // called when job is done $req->wakeup(); // wake up the request immediately }); $job('request', function ($name, $job) { // registering job named 'showvar' $httpclient = HTTPClient::getInstance(); $cb = function ($conn, $success) use($name, $job) { $job->setResult($name, $conn->body); }; //$httpclient->get(['http://phpdaemon.net/Example/', 'foo' => 'bar'], $cb); $httpclient->post(['http://phpdaemon.net/Example/', 'foo' => 'bar'], ['postField' => 'value'], $cb); }); $job(); // let the fun begin $this->sleep(5, true); // setting timeout }