Transporter::asyncRead PHP Method

asyncRead() private method

private asyncRead ( $stream, $o )
    private function asyncRead($stream, $o)
    {
        $response = $this->getResponse($stream, $o);
        if ($response === false) {
            $this->asyncReadError($o, $stream, -1);
            return;
        }
        if ($response->length === false) {
            $this->asyncReadError($o, $stream, $response->index);
            return;
        }
        $remaining = $response->length - strlen($response->buffer);
        $buffer = @fread($stream, $remaining);
        if (empty($buffer)) {
            $this->asyncReadError($o, $stream, $response->index);
            return;
        }
        $response->buffer .= $buffer;
        if (strlen($response->buffer) === $response->length) {
            if (isset($o->results[$response->index])) {
                $result = $o->results[$response->index];
                $this->free($o, $response->index);
            }
            $stream_id = (int) $stream;
            unset($o->responses[$stream_id]);
            $this->afterRead($stream, $o, $response);
            if (isset($result)) {
                $result->resolve($response->buffer);
            }
        }
    }