public function __construct($message = null, $code = null, $file = null, $line = null) { JAXLLogger::notice("got jaxl exception construct with {$message}, {$code}, {$file}, {$line}"); if ($code === null) { parent::__construct($message); } else { parent::__construct($message, $code); } if ($file !== null) { $this->file = $file; } if ($line !== null) { $this->line = $line; } }
function wait_for_register_response($event, $args) { global $client, $form; if ($event == 'stanza_cb') { $stanza = $args[0]; if ($stanza->name == 'iq') { $form['type'] = $stanza->attrs['type']; if ($stanza->attrs['type'] == 'result') { echo "registration successful" . PHP_EOL . "shutting down..." . PHP_EOL; $client->send_end_stream(); return "logged_out"; } elseif ($stanza->attrs['type'] == 'error') { $error = $stanza->exists('error'); echo sprintf("registration failed with error code: %s and type: %s" . PHP_EOL, $error->attrs['code'], $error->attrs['type']); echo "error text: " . $error->exists('text')->text . PHP_EOL; echo "shutting down..." . PHP_EOL; $client->send_end_stream(); return "logged_out"; } } } else { JAXLLogger::notice("unhandled event {$event} rcvd"); } }
public function handle_invalid_state($r) { JAXLLogger::error(sprintf("got invalid return value from state handler '%s', sending end stream...", $this->state)); $this->send_end_stream(); $this->state = "logged_out"; JAXLLogger::notice(sprintf("state handler '%s' returned %s, kindly report this to developers", $this->state, serialize($r))); }
/** * @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"); } }