INNER CODE UNIT · Python

websocket_moderator_endpoint

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

async def websocket_moderator_endpoint(websocket: WebSocket,
                             chat_info: dict = Depends(chat_info_vars)):
    # check the user is allowed into the chat room
    # verified = await verify_user_for_room(chat_info)
    # open connection

    if not chat_info['username'] == 'moderator':
        print('failed verification')
        await websocket.close()
        return

    await websocket.accept()
    # spin up coro's for inbound and outbound communication over the socket
    await asyncio.gather(ws_send_moderator(websocket, chat_info))


@app.get("/")
async def get(request: Request):

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…