INNER CODE UNIT · Python

announce

leonh/redis-streams-fastapi-chat · chat.py:280

async def announce(pool, chat_info: dict, action: str):
    """
    add an announcement event onto the redis chat stream
    """
    users = await room_users(chat_info, pool)
    fields = {
        'msg': f"{chat_info['username']} {action}",
        'action': action,
        'type': 'announcement',
        'users': ", ".join(users),
        'room': chat_info['room']
    }
    #print(fields)

    await pool.xadd(
        name=cvar_tenant.get() + ":stream",
        fields=fields,
        id='*',

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…