/** * 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; }
/** * 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(); }
/** * @param string $exchange * @param string $routingKey * @param bool $mandatory * @param bool $immediate * @param string $ticket * * @return \AMQP\Wire\Writer */ public function basicPublish($options) { $args = new Writer(); $args->writeShort($options['ticket'])->writeShortStr($options['exchange'])->writeShortStr($options['routing_key'])->writeBit($options['mandatory'])->writeBit($options['immediate']); return $args; }