protected function readHeaders()
{
$topByte = $this->readByte();
// ignore the first two bytes -- version or something
$secondByte = $this->readByte();
//0 for Flash,
//If firstByte != 0, then the Amf data is corrupted, for example the transmission
//
if (!($topByte == 0 || $topByte == 3)) {
throw new Amfphp_Core_Exception('Malformed Amf Packet, connection may have dropped');
}
if ($secondByte == 3) {
$this->deserializedPacket->amfVersion = Amfphp_Core_Amf_Constants::AMF3_ENCODING;
}
$this->headersLeftToProcess = $this->readInt();
// find the total number of header elements
while ($this->headersLeftToProcess--) {
// loop over all of the header elements
$this->resetReferences();
$name = $this->readUTF();
$required = $this->readByte() == 1;
// find the must understand flag
//$length = $this->readLong(); // grab the length of the header element
$this->currentByte += 4;
// grab the length of the header element
$type = $this->readByte();
// grab the type of the element
$content = $this->readData($type);
// turn the element into real data
$header = new Amfphp_Core_Amf_Header($name, $required, $content);
$this->deserializedPacket->headers[] = $header;
}
}