(websocket: WebSocket, client_id: int)
| 100 | |
| 101 | @app.websocket("/cartoon_ws/{client_id}") |
| 102 | async def process_cartoon_ws(websocket: WebSocket, client_id: int): |
| 103 | await conn_mgr.connect(websocket) |
| 104 | try: |
| 105 | while True: |
| 106 | received = await websocket.receive_text() |
| 107 | |
| 108 | # Process request |
| 109 | result = process_incoming_request(received) |
| 110 | |
| 111 | # Send back the result |
| 112 | await conn_mgr.send_message(json.dumps(result), websocket) |
| 113 | |
| 114 | except WebSocketDisconnect: |
| 115 | conn_mgr.disconnect(websocket) |
| 116 | await conn_mgr.broadcast(f"Client #{client_id} left the chat") |
| 117 | |
| 118 | |
| 119 | if __name__ == "__main__": |
nothing calls this directly
no test coverage detected