INNER CODE UNIT · Python
websocket_endpoint
leonh/redis-streams-fastapi-chat · chat.py:316
async def websocket_endpoint(websocket: WebSocket,
chat_info: dict = Depends(chat_info_vars)):
#print('request.hostname', websocket.url.hostname)
tenant_id = ":".join([websocket.url.hostname.replace('.', '_'),
chat_info['room']])
cvar_tenant.set(tenant_id)
cvar_chat_info.set(chat_info)
# check the user is allowed into the chat room
verified = await verify_user_for_room(chat_info)
# open connection
await websocket.accept()
if not verified:
print('failed verification')
print(chat_info)
await websocket.close()