'Acts on extracted protocol messages based on header flags.
After the incoming `data\' is decrypted and authenticated, this method
processes the received data based on the header flags.  Payload is
written to the local application, new tickets are stored, or keys are
added to the replay table.'

def processMessages(self, data):

    if ((data is None) or (len(data) == 0)):
        return
    msgs = self.protoMsg.extract(data, self.recvCrypter, self.recvHMAC)
    if ((msgs is None) or (len(msgs) == 0)):
        return
    for msg in msgs:
        if (msg.flags == const.FLAG_PAYLOAD):
            self.circuit.upstream.write(msg.payload)
        elif (self.weAreClient and (msg.flags == const.FLAG_NEW_TICKET)):
            assert (len(msg.payload) == (const.TICKET_LENGTH + const.MASTER_KEY_LENGTH))
            peer = self.circuit.downstream.transport.getPeer()
        elif (self.weAreClient and (msg.flags == const.FLAG_PRNG_SEED)):
            assert (len(msg.payload) == const.PRNG_SEED_LENGTH)
            prng = random.Random(msg.payload)
            pktDist = probdist.new((lambda : prng.randint(const.HDR_LENGTH, const.MTU)), seed=msg.payload)
            self.pktMorpher = packetmorpher.new(pktDist)
            self.iatMorpher = probdist.new((lambda : (prng.random() % const.MAX_PACKET_DELAY)), seed=msg.payload)
        else:
            pass
