def _flush_message_buffer(self):
        """
        Loops through the transport message_buffer until there are no messages
        left in the queue. Each response is assigned to the Request object
        based on the message_id which are then available in
        self.outstanding_requests
        """
        while True:
            message_bytes = self.transport.receive()

            # there were no messages receives, so break from the loop
            if message_bytes is None:
                break

            # check if the message is encrypted and decrypt if necessary
            if message_bytes[:4] == b"\xfdSMB":
                message = SMB2TransformHeader()
                message.unpack(message_bytes)
                message_bytes = self._decrypt(message)

            # now retrieve message(s) from response
            is_last = False
            session_id = None
            while not is_last:
                next_command = struct.unpack("<L", message_bytes[20:24])[0]
                header_length = \
                    next_command if next_command != 0 else len(message_bytes)
                header_bytes = message_bytes[:header_length]
                message = SMB2HeaderResponse()
                message.unpack(header_bytes)

                flags = message['flags']
                if not flags.has_flag(Smb2Flags.SMB2_FLAGS_RELATED_OPERATIONS):
                    session_id = message['session_id'].get_value()

                self._verify(message, session_id)
                message_id = message['message_id'].get_value()
                request = self.outstanding_requests.get(message_id, None)
                if not request:
                    error_msg = "Received response with an unknown message " \
                                "ID: %d" % message_id
                    raise smbprotocol.exceptions.SMBException(error_msg)

                # add the upper credit limit based on the credits granted by
                # the server
                credit_response = message['credit_response'].get_value()
                self.sequence_window['high'] += \
                    credit_response if credit_response > 0 else 1

                request.response = message
                self.outstanding_requests[message_id] = request

                message_bytes = message_bytes[header_length:]
                is_last = next_command == 0
Loops through the transport message_buffer until there are no messages
        left in the queue. Each response is assigned to the Request object
        based on the message_id which are then available in
        self.outstanding_requests