/** * @param $client_properties * @param $mechanism * @param $response * @param $locale */ protected function x_start_ok($client_properties, $mechanism, $response, $locale) { $args = new AMQPWriter(); $args->write_table($client_properties); $args->write_shortstr($mechanism); $args->write_longstr($response); $args->write_shortstr($locale); $this->send_method_frame(array(10, 11), $args); }
public function testTable($table, $integer_op, $string_op) { $args = new AMQPWriter(); $args->write_table($table); $args->write_octet($integer_op); $args->write_octet($string_op); return array(120, 30, $args); }
/** * @param integer $ticket * @param string $queue * @param string $consumer_tag * @param boolean $no_local * @param boolean $no_ack * @param boolean $exclusive * @param boolean $nowait * @param array $arguments * @return array */ public function basicConsume($ticket = 0, $queue = '', $consumer_tag = '', $no_local = false, $no_ack = false, $exclusive = false, $nowait = false, $arguments = array()) { $writer = new AMQPWriter(); $writer->write_short($ticket); $writer->write_shortstr($queue); $writer->write_shortstr($consumer_tag); $writer->write_bits(array($no_local, $no_ack, $exclusive, $nowait)); $writer->write_table(empty($arguments) ? array() : $arguments); return array(60, 20, $writer); }
/** * @param mixed $table * @param mixed $integer_op * @param mixed $string_op * @return array */ public function testTable($table, $integer_op, $string_op) { $writer = new AMQPWriter(); $writer->write_table(empty($table) ? array() : $table); $writer->write_octet($integer_op); $writer->write_octet($string_op); return array(120, 30, $writer); }
public function testWriteTableThrowsExceptionOnInvalidType() { $this->setExpectedException('PhpAmqpLib\\Exception\\AMQPInvalidArgumentException', "Invalid type '_'"); $this->_writer->write_table(array('x-foo' => array('_', 'bar'))); }
public function testTableWriteReadCollection() { $w = new AMQPWriter(); $w->write_table(new AMQPTable(array('long' => 12345, 'long_neg' => -12345, 'longlong' => 3000000000, 'longlong_neg' => -3000000000, 'float_low' => 9.2233720368548, 'float_high' => (double) 9.2233720368548E+18, 'bool_true' => true, 'bool_false' => false, 'array' => array(1, 2, 3, 'foo', array('bar' => 'baz'), array('boo', false, 5), true), 'array_empty' => array(), 'table' => array('foo' => 'bar', 'baz' => 'boo', 'bool' => true, 'tbl' => array('bar' => 'baz'), 'arr' => array('boo', false, 5)), 'table_num' => array(1 => 5, 3 => 'foo', 786 => 674), 'array_nested' => array(1, array(2, array(3, array(4)))), 'table_nested' => array('i' => 1, 'n' => array('i' => 2, 'n' => array('i' => 3, 'n' => array('i' => 4))))))); $r = new AMQPReader($w->getvalue()); //type casting - thanks to ancient phpunit on travis $this->assertEquals(array('long' => 12345, 'long_neg' => -12345, 'longlong' => (string) 3000000000, 'longlong_neg' => (string) -3000000000, 'float_low' => (string) (double) 9.2233720368548, 'float_high' => (string) (double) 9.2233720368548E+18, 'bool_true' => true, 'bool_false' => false, 'array' => array(1, 2, 3, 'foo', array('bar' => 'baz'), array('boo', false, 5), true), 'array_empty' => array(), 'table' => array('foo' => 'bar', 'baz' => 'boo', 'bool' => true, 'tbl' => array('bar' => 'baz'), 'arr' => array('boo', false, 5)), 'table_num' => array(1 => 5, 3 => 'foo', 786 => 674), 'array_nested' => array(1, array(2, array(3, array(4)))), 'table_nested' => array('i' => 1, 'n' => array('i' => 2, 'n' => array('i' => 3, 'n' => array('i' => 4))))), $r->read_table(true)->getNativeData()); }
public function basicConsume($ticket = 0, $queue = '', $consumer_tag = '', $no_local = false, $no_ack = false, $exclusive = false, $nowait = false, $arguments = array()) { $args = new AMQPWriter(); $args->write_short($ticket); $args->write_shortstr($queue); $args->write_shortstr($consumer_tag); $args->write_bit($no_local); $args->write_bit($no_ack); $args->write_bit($exclusive); $args->write_bit($nowait); $args->write_table($arguments); return array(60, 20, $args); }
/** * Write PHP array, as table. Input array format: keys are strings, * values are (type,value) tuples. */ public function write_table($d) { $table_data = new 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 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); } elseif ($ftype == 't') { $table_data->write('t'); $table_data->write_octet($v ? 1 : 0); } else { throw new AMQPInvalidArgumentException(sprintf("Invalid type '%s'", $ftype)); } } $table_data = $table_data->getvalue(); $this->write_long(strlen($table_data)); $this->write($table_data); return $this; }