def METHOD_NAME(cls, raw):
    """
    Given a possibly-multiline string representing an SSE message, parse it
    and return a Event object.
    """
    msg = cls()
    for line in raw.splitlines():
        m = cls.sse_line_pattern.match(line)
        if m is None:
            # Malformed line.  Discard but warn.
            warnings.warn('Invalid SSE line: "%s"' % line, SyntaxWarning)
            continue
        name = m.group('name')
        if name == '':
            # line began with a ":", so is a comment.  Ignore
            continue
        value = m.group('value')
        if name == 'data':
            # If we already have some data, then join to it with a newline.
            # Else this is it.
            if msg.data:
                msg.data = '%s\n%s' % (msg.data, value)
            else:
                msg.data = value
        elif name == 'event':
            msg.event = value
        elif name == 'id':
            msg.id = value
        elif name == 'retry':
            msg.retry = int(value)
    return msg