JAXLPipe::__construct PHP Method

__construct() public method

public __construct ( string $name, callable $read_cb = null )
$name string
$read_cb callable TODO: Currently not used
    public function __construct($name, $read_cb = null)
    {
        // TODO: see JAXL->cfg['priv_dir']
        $this->pipes_folder = getcwd() . '/.jaxl/pipes';
        if (!is_dir($this->pipes_folder)) {
            mkdir($this->pipes_folder, 0777, true);
        }
        $this->ev = new JAXLEvent();
        $this->name = $name;
        // TODO: If someone's need the read callback and extends the JAXLPipe
        // to obtain it, one can't because this property is private.
        $this->read_cb = $read_cb;
        $pipe_path = $this->get_pipe_file_path();
        if (!file_exists($pipe_path)) {
            posix_mkfifo($pipe_path, $this->perm);
            $this->fd = fopen($pipe_path, 'r+');
            if (!$this->fd) {
                JAXLLogger::error("unable to open pipe");
            } else {
                JAXLLogger::debug("pipe opened using path {$pipe_path}");
                JAXLLogger::notice("Usage: \$ echo 'Hello World!' > {$pipe_path}");
                $this->client = new JAXLSocketClient();
                $this->client->connect($this->fd);
                $this->client->set_callback(array(&$this, 'on_data'));
            }
        } else {
            JAXLLogger::error("pipe with name {$name} already exists");
        }
    }