function wait_content() { $frm = $this->next_frame(); $frame_type = $frm[0]; $payload = $frm[1]; if ($frame_type != 2) { throw new Exception("Expecting Content header"); } $payload_reader = new AMQP_Reader(substr($payload, 0, 12)); $class_id = $payload_reader->read_short(); $weight = $payload_reader->read_short(); $body_size = $payload_reader->read_longlong(); $msg = new AMQP_Message(); $msg->load_properties(substr($payload, 12)); $body_parts = array(); $body_received = 0; while (bccomp($body_size, $body_received) == 1) { $frm = $this->next_frame(); $frame_type = $frm[0]; $payload = $frm[1]; if ($frame_type != 3) { throw new Exception("Expecting Content body, received frame type {$frame_type}"); } $body_parts[] = $payload; $body_received = bcadd($body_received, strlen($payload)); } $msg->body = implode("", $body_parts); if ($this->auto_decode and isset($msg->content_encoding)) { try { $msg->body = $msg->body->decode($msg->content_encoding); } catch (Exception $e) { self::debug_msg("Ignoring body decoding exception: " . $e->getMessage()); } } return $msg; }