コード例 #1
0
 public function testTableWriteReadCollection()
 {
     $w = new AMQPBufferWriter();
     $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 AMQPBufferReader($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());
 }
コード例 #2
0
 /**
  * Output heartbeat loop
  */
 public function outputHeartbeatLoop()
 {
     while ($this->isOpen()) {
         (yield Awaitable\resolve()->delay($this->heartbeat));
         if (!$this->something_sent_between_heartbeat_checks) {
             $pkt = new AMQPBufferWriter();
             $pkt->write_octet(FrameTypes::HEARTBEAT);
             $pkt->write_short(0);
             $pkt->write_long(0);
             $pkt->write_octet(Constants091::FRAME_END);
             (yield $this->client->write($pkt->getvalue()));
         } else {
             $this->something_sent_between_heartbeat_checks = false;
         }
     }
 }
コード例 #3
0
 /**
  * @return array
  */
 public function txRollback()
 {
     $args = new AMQPBufferWriter();
     return [ClassTypes::TX, TxMethods::ROLLBACK, $args->getvalue()];
 }