Emits on on_read_ready.
public set_callback ( callable $recv_cb ) | ||
$recv_cb | callable |
/** * @param string $name * @param callable $read_cb 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"); } }
/** * @param string $transport */ public function __construct($transport = 'tcp') { $this->transport = $transport; $this->client = new JAXLSocketClient(); $this->client->set_callback(array(&$this, 'on_response')); }