protected function send_channel_method_frame($channel, $method_sig, $args = "") { if (is_a($args, "AMQP_Writer")) { $args = $args->getvalue(); } $pkt = new AMQP_Writer(); $pkt->write_octet(1); $pkt->write_short($channel); $pkt->write_long(strlen($args) + 4); // 4 = length of class_id and method_id // in payload $pkt->write_short($method_sig[0]); // class_id $pkt->write_short($method_sig[1]); // method_id $pkt->write($args); $pkt->write_octet(0xce); $pkt = $pkt->getvalue(); $this->write($pkt); self::debug_msg("< " . self::methodSig($method_sig) . ": " . AMQP_Core::$METHOD_NAME_MAP[self::methodSig($method_sig)]); }
/** * Write PHP array, as table. Input array format: keys are strings, * values are (type,value) tuples. */ public function write_table($d) { $this->flushbits(); $table_data = new AMQP_Writer(); 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); } else { if ($ftype == 'I') { $table_data->write('I'); $table_data->write_signed_long($v); } else { if ($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); } else { if ($ftype == 'T') { $table_data->write('T'); $table_data->write_timestamp($v); } else { if ($ftype = 'F') { $table_data->write('F'); $table_data->write_table($v); } } } } } } $table_data = $table_data->getvalue(); $this->write_long(strlen($table_data)); $this->write($table_data); }