/** * @return array */ public function connectionStart($version_major = 0, $version_minor = 9, $server_properties, $mechanisms = 'PLAIN', $locales = 'en_US') { $args = new PhpAmqpLib_Wire_AMQPWriter(); $args->write_octet($version_major); $args->write_octet($version_minor); $args->write_table(empty($server_properties) ? array() : $server_properties); $args->write_longstr($mechanisms); $args->write_longstr($locales); return array(10, 10, $args); }
/** * Write PHP array, as table. Input array format: keys are strings, * values are (type,value) tuples. */ public function write_table($d) { $this->flushbits(); $table_data = new PhpAmqpLib_Wire_AMQPWriter(); foreach ($d as $k => $va) { list($ftype, $v) = $va; $table_data->write_shortstr($k); if ($ftype == 'S') { $table_data->write('S'); $table_data->write_longstr($v); } elseif ($ftype == 'I') { $table_data->write('I'); $table_data->write_signed_long($v); } elseif ($ftype == 'D') { // 'D' type values are passed PhpAmqpLib_Wire_AMQPDecimal instances. $table_data->write('D'); $table_data->write_octet($v->e); $table_data->write_signed_long($v->n); } elseif ($ftype == 'T') { $table_data->write('T'); $table_data->write_timestamp($v); } elseif ($ftype == 'F') { $table_data->write('F'); $table_data->write_table($v); } elseif ($ftype == 'A') { $table_data->write('A'); $table_data->write_array($v); } else { throw new \InvalidArgumentException(sprintf("Invalid type '%s'", $ftype)); } } $table_data = $table_data->getvalue(); $this->write_long(strlen($table_data)); $this->write($table_data); return $this; }
public function testTable($table, $integer_op, $string_op) { $args = new PhpAmqpLib_Wire_AMQPWriter(); $args->write_table($table); $args->write_octet($integer_op); $args->write_octet($string_op); return array(120, 30, $args); }
/** * Sends a heartbeat message */ protected function write_heartbeat() { $pkt = new PhpAmqpLib_Wire_AMQPWriter(); $pkt->write_octet(8); $pkt->write_short(0); $pkt->write_long(0); $pkt->write_octet(0xce); $this->write($pkt->getvalue()); }
/** * Returns a new PhpAmqpLib_Wire_AMQPWriter or mutates the provided $pkt * * @param $channel * @param $method_sig * @param string $args * @param PhpAmqpLib_Wire_AMQPWriter $pkt * @return null|PhpAmqpLib_Wire_AMQPWriter */ protected function prepare_channel_method_frame($channel, $method_sig, $args = '', $pkt = null) { if ($args instanceof PhpAmqpLib_Wire_AMQPWriter) { $args = $args->getvalue(); } if (empty($pkt)) { $pkt = new PhpAmqpLib_Wire_AMQPWriter(); } $pkt->write_octet(1); $pkt->write_short($channel); $pkt->write_long(mb_strlen($args, 'ASCII') + 4); // 4 = length of class_id and method_id // in payload $pkt->write_short($method_sig[0]); // class_id $pkt->write_short($method_sig[1]); // method_id $pkt->write($args); $pkt->write_octet(0xce); if ($this->debug) { $PROTOCOL_CONSTANTS_CLASS = self::$PROTOCOL_CONSTANTS_CLASS; $GLOBAL_METHOD_NAMES = self::getStaticProperty($PROTOCOL_CONSTANTS_CLASS, 'GLOBAL_METHOD_NAMES'); PhpAmqpLib_Helper_MiscHelper::debug_msg(sprintf('< %s: %s', PhpAmqpLib_Helper_MiscHelper::methodSig($method_sig), $GLOBAL_METHOD_NAMES[PhpAmqpLib_Helper_MiscHelper::methodSig($method_sig)])); } return $pkt; }
protected function send_channel_method_frame($channel, $method_sig, $args = "") { if ($args instanceof PhpAmqpLib_Wire_AMQPWriter) { $args = $args->getvalue(); } $pkt = new PhpAmqpLib_Wire_AMQPWriter(); $pkt->write_octet(1); $pkt->write_short($channel); $pkt->write_long(strlen($args) + 4); // 4 = length of class_id and method_id // in payload $pkt->write_short($method_sig[0]); // class_id $pkt->write_short($method_sig[1]); // method_id $pkt->write($args); $pkt->write_octet(0xce); $pkt = $pkt->getvalue(); $this->write($pkt); if ($this->debug) { $PROTOCOL_CONSTANTS_CLASS = self::$PROTOCOL_CONSTANTS_CLASS; PhpAmqpLib_Helper_MiscHelper::debug_msg("< " . PhpAmqpLib_Helper_MiscHelper::methodSig($method_sig) . ": " . $PROTOCOL_CONSTANTS_CLASS::$GLOBAL_METHOD_NAMES[PhpAmqpLib_Helper_MiscHelper::methodSig($method_sig)]); } }