Exemplo n.º 1
0
 /**
  * @param integer $ticket
  * @param string $queue
  * @param boolean $no_ack
  * @return array
  */
 public function basicGet($ticket = 0, $queue = '', $no_ack = false)
 {
     $writer = new AMQPWriter();
     $writer->write_short($ticket);
     $writer->write_shortstr($queue);
     $writer->write_bits(array($no_ack));
     return array(60, 70, $writer);
 }
Exemplo n.º 2
0
 /**
  * @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);
 }
Exemplo n.º 3
0
 /**
  * Write PHP array, as table. Input array format: keys are strings,
  * values are (type,value) tuples.
  *
  * @param AMQPTable|array $d Instance of AMQPTable or PHP array WITH format hints (unlike write_array())
  * @return $this
  * @throws \PhpAmqpLib\Exception\AMQPInvalidArgumentException
  */
 public function write_table($d)
 {
     $typeIsSym = !$d instanceof AMQPTable;
     //purely for back-compat purposes
     $table_data = new AMQPWriter();
     foreach ($d as $k => $va) {
         list($ftype, $v) = $va;
         $table_data->write_shortstr($k);
         $table_data->write_value($typeIsSym ? AMQPAbstractCollection::getDataTypeForSymbol($ftype) : $ftype, $v);
     }
     $table_data = $table_data->getvalue();
     $this->write_long(mb_strlen($table_data, 'ASCII'));
     $this->write($table_data);
     return $this;
 }
Exemplo n.º 4
0
 public function testString($string_1, $string_2, $operation)
 {
     $args = new AMQPWriter();
     $args->write_shortstr($string_1);
     $args->write_longstr($string_2);
     $args->write_octet($operation);
     return array(120, 20, $args);
 }
Exemplo n.º 5
0
 public function basicGet($ticket = 0, $queue = '', $no_ack = false)
 {
     $args = new AMQPWriter();
     $args->write_short($ticket);
     $args->write_shortstr($queue);
     $args->write_bit($no_ack);
     return array(60, 70, $args);
 }
Exemplo n.º 6
0
 /**
  * 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;
 }
Exemplo n.º 7
0
 public function basicCancel($consumer_tag, $nowait)
 {
     $args = new AMQPWriter();
     $args->write_shortstr($consumer_tag)->write_bit($nowait);
     return $args;
 }