示例#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);
 }
示例#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();
 }
示例#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;
 }
示例#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;
 }
示例#5
0
文件: WireTest.php 项目: zircote/amqp
 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}());
 }