'Find frames in incoming data and pass them to the underlying protocol.'

def parseFrames(self):

    if (self.flavor == HYBI00):
        parser = parse_hybi00_frames
    elif (self.flavor in (HYBI07, HYBI10, RFC6455)):
        parser = parse_hybi07_frames
    else:
        raise WSException(('Unknown    flavor    %r' % self.flavor))
    try:
        (frames, self.buf) = parser(self.buf)
    except WSException as wse:
        self.close(wse.args[0])
        return
    for frame in frames:
        (opcode, data) = frame
        if (opcode == NORMAL):
            if self.codec:
                data = decoders[self.codec](data)
            ProtocolWrapper.dataReceived(self, data)
        elif (opcode == CLOSE):
            (reason, text) = data
            log.msg(('Closing    connection:    %r    (%d)' % (text, reason)))
            self.close()
