def sse_pack(d):
    """For sending sse to client. Formats a dictionary into correct form for SSE"""
    buf = ''
    for k in ['retry','id','event','data']:
        if k in d.keys():
            buf += '{}: {}\n'.format(k, d[k])
    return buf + '\n'