fix(chat.py): add comment explaining the behavior of accepting and immediately closing the connection if the flow is not built yet
This commit is contained in:
parent
d46aeb2efa
commit
e9b44ac781
1 changed files with 2 additions and 0 deletions
|
|
@ -19,6 +19,8 @@ async def chat(client_id: str, websocket: WebSocket):
|
||||||
if client_id in chat_manager.in_memory_cache:
|
if client_id in chat_manager.in_memory_cache:
|
||||||
await chat_manager.handle_websocket(client_id, websocket)
|
await chat_manager.handle_websocket(client_id, websocket)
|
||||||
else:
|
else:
|
||||||
|
# We accept the connection but close it immediately
|
||||||
|
# if the flow is not built yet
|
||||||
await websocket.accept()
|
await websocket.accept()
|
||||||
message = "Please, build the flow before sending messages"
|
message = "Please, build the flow before sending messages"
|
||||||
await websocket.close(code=status.WS_1011_INTERNAL_ERROR, reason=message)
|
await websocket.close(code=status.WS_1011_INTERNAL_ERROR, reason=message)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue