/** * @memcheck */ public function testDisconnect() { list($one, $this->tmp) = IPC::create((string) "one1", (string) "two2"); /* @var IPC $one */ /* @var IPC $two */ $one->whenIncoming()->then(function ($data) { $this->data[] = $data; }); $one->whenDisconnected()->then(function ($ctx) { $this->data[] = $ctx; }); \ION::await(0.02)->then(function () { $this->tmp->send("test1"); }); \ION::await(0.03)->then(function () { unset($this->tmp); }); \ION::await(0.04)->then(function () { $this->stop(); }); \ION::dispatch(); $this->assertEquals([$this->message("test1", "one1"), "one1"], $this->data); }
$request->onBody($parser)->then(function (\ION\HTTP\WebSocket\Frame $frame) { }); while (!$parser->isFinished()) { $frame = (yield $request->onBody($parser)); } $parser = new \ION\HTTP\MultiPartParser("iddqd", 1000); $request->onBody($parser)->then(function (\ION\HTTP\MultiPart\Part $part) { }); while (!$parser->isFinished()) { $part = (yield $request->onBody($parser)); } $parser = new \ION\HTTP\ChunkedParser(); $request->onBody($parser)->then(function (string $chunk) { }); while (!$parser->isFinished()) { $chunk = (yield $request->onBody($parser)); } $response = (yield \ION\HTTP::request($request)); /* @var \ION\HTTP\Response $response */ echo "Code: " . $response->getStatusCode() . " (" . $response->getReasonPhrase() . ")\n\n"; echo "Headers: \n\n"; var_dump($response->getHeaders()); echo "Content: \n\n"; var_dump($response->getBody()); echo "\n\n"; }); $init = function ($request) { throw \ION\Sequence::quit(); }; ION::dispatch();