/** * This method allows the server to send a non-fatal warning to * the client. This is used for methods that are normally * asynchronous and thus do not have confirmations, and for which * the server may detect errors that need to be reported. Fatal * errors are handled as channel or connection exceptions; non- * fatal errors are sent through this method. * * @param \AMQP\Wire\Reader $args */ protected function alert(\AMQP\Wire\Reader $args) { $replyCode = $args->readShort(); $replyText = $args->readShortstr(); $details = $args->readTable(); array_push($this->alerts, array($replyCode, $replyText, $details)); }
/** * Read an AMQP table, and return as a PHP array. keys are strings, * values are (type,value) tuples. * * @return array * @throws \Exception */ public function readTable() { $this->_bitcount = $this->_bits = 0; $tlen = $this->readPhpInt(); if ($tlen < 0) { throw new \Exception('Table is longer than supported'); } $tableData = new Reader($this->_rawread($tlen)); $result = array(); while ($tableData->tell() < $tlen) { $name = $tableData->readShortstr(); $ftype = $tableData->_rawread(1); if ($ftype == 'S') { $val = $tableData->readLongstr(); } else { if ($ftype == 'I') { $val = $tableData->_readSignedLong(); } else { if ($ftype == 'D') { $e = $tableData->readOctet(); $n = $tableData->_readSignedLong(); $val = new Decimal($n, $e); } else { if ($ftype == 'T') { $val = $tableData->readTimestamp(); } else { if ($ftype == 'F') { $val = $tableData->readTable(); // recursion } else { error_log(sprintf('Usupported table field type %s', $ftype)); $val = null; } } } } } $result[$name] = array($ftype, $val); } return $result; }
/** * start connection negotiation */ protected function start(Reader $args) { $this->versionMajor = $args->readOctet(); $this->versionMinor = $args->readOctet(); $this->serverProperties = $args->readTable(); $this->mechanisms = explode(" ", $args->readLongstr()); $this->locales = explode(" ", $args->readLongstr()); if ($this->debug) { Helper::debugMsg(sprintf('Start from server, version: %d.%d, properties: %s, ' . 'mechanisms: %s, locales: %s', $this->versionMajor, $this->versionMinor, self::dumpTable($this->serverProperties), implode(', ', $this->mechanisms), implode(', ', $this->locales))); } }