JAXLSocketClient::on_read_ready PHP Method

on_read_ready() public method

public on_read_ready ( $fd )
    public function on_read_ready($fd)
    {
        //JAXLLogger::debug("on read ready called");
        $raw = @fread($fd, $this->recv_chunk_size);
        $bytes = strlen($raw);
        if ($bytes === 0) {
            $meta = stream_get_meta_data($fd);
            if ($meta['eof'] === true) {
                JAXLLogger::warning("socket eof, disconnecting");
                JAXLLoop::unwatch($fd, array('read' => true));
                $this->disconnect();
                return;
            }
        }
        $this->recv_bytes += $bytes;
        $total = $this->ibuffer . $raw;
        $this->ibuffer = "";
        JAXLLogger::debug("read " . $bytes . "/" . $this->recv_bytes . " of data");
        if ($bytes > 0) {
            JAXLLogger::debug($raw);
        }
        // callback
        if ($this->recv_cb) {
            call_user_func($this->recv_cb, $raw);
        }
    }