Handle WebSocket connections - one command per connection
(websocket, path=None)
| 438 | await websocket.send(json.dumps({"error": f"Command failed: {str(e)}"})) |
| 439 | |
| 440 | async def websocket_handler(websocket, path=None): |
| 441 | """Handle WebSocket connections - one command per connection""" |
| 442 | connected_clients.add(websocket) |
| 443 | logger.info(f"Client connected. Total clients: {len(connected_clients)}") |
| 444 | |
| 445 | try: |
| 446 | await handle_single_command(websocket) |
| 447 | except websockets.exceptions.ConnectionClosed: |
| 448 | logger.info("Client disconnected normally") |
| 449 | except Exception as e: |
| 450 | logger.error(f"Session error: {str(e)}") |
| 451 | finally: |
| 452 | connected_clients.remove(websocket) |
| 453 | logger.info(f"Client removed. Total clients: {len(connected_clients)}") |
| 454 | |
| 455 | async def main(): |
| 456 | """Start the WebSocket server""" |
nothing calls this directly
no test coverage detected