Exemplo n.º 1
0
 public function testWriteArray()
 {
     $this->_writer->writeArray(array('rabbit@localhost', 'hare@localhost'));
     $out = $this->_writer->getvalue();
     $this->assertEquals(44, strlen($out));
     $expected = "(Srabbit@localhostShare@localhost";
     $this->assertEquals($expected, $out);
 }
Exemplo n.º 2
0
 /**
  * serialize the 'properties' attribute (a dictionary) into the
  * raw bytes making up a set of property flags and a property
  * list, suitable for putting into a content frame header.
  */
 public function serializeProperties()
 {
     $shift = 15;
     $flagBits = 0;
     $flags = array();
     $rawBytes = new Writer();
     foreach ($this->propertyTypes as $key => $proptype) {
         if (isset($this->properties[$key])) {
             $value = $this->properties[$key];
         } else {
             $value = null;
         }
         if ($value != null) {
             if ($shift == 0) {
                 $flags[] = $flagBits;
                 $flagBits = 0;
                 $shift = 15;
             }
             $flagBits |= 1 << $shift;
             if ($proptype != 'bit') {
                 $proptype = ucfirst($proptype);
                 $rawBytes->{'write' . $proptype}($value);
             }
         }
         $shift -= 1;
     }
     $flags[] = $flagBits;
     $result = new Writer();
     foreach ($flags as $flagBits) {
         $result->writeShort($flagBits);
     }
     $result->write($rawBytes->getvalue());
     return $result->getvalue();
 }
Exemplo n.º 3
0
 /**
  * negotiate connection tuning parameters
  *
  * @param $channelMax
  * @param $frameMax
  * @param $heartbeat
  */
 protected function xTuneOk($channelMax, $frameMax, $heartbeat)
 {
     $args = new Writer();
     $args->writeShort($channelMax);
     $args->writeLong($frameMax);
     $args->writeShort($heartbeat);
     $this->sendMethodFrame(array(10, 31), $args);
     $this->waitTuneOk = False;
 }
Exemplo n.º 4
0
 /**
  * @param string $deliveryTag
  * @param bool   $reQueue
  *
  * @return \AMQP\Wire\Writer
  */
 public function basicReject($deliveryTag, $reQueue)
 {
     $args = new Writer();
     $args->writeLongLong($deliveryTag)->writeBit($reQueue);
     return $args;
 }
Exemplo n.º 5
0
 protected function writeAndRead($v, $write_method, $read_method)
 {
     $w = new Writer();
     $w->{$write_method}($v);
     $r = new Reader($w->getvalue());
     $this->assertEquals($v, $r->{$read_method}());
 }