(ws: ServerConnection)
| 365 | |
| 366 | # WebSocket handler |
| 367 | async def ws_handler(ws: ServerConnection) -> None: |
| 368 | bridge.set_ws(ws) |
| 369 | logger.info("WebSocket connected for app %s", app_info.tool_name) |
| 370 | |
| 371 | # Drain any notifications that queued while WS was disconnected |
| 372 | await bridge.drain_pending() |
| 373 | |
| 374 | try: |
| 375 | async for message in ws: |
| 376 | if isinstance(message, str): |
| 377 | response = await bridge.handle_message(message) |
| 378 | if response: |
| 379 | await ws.send(response) |
| 380 | except websockets.ConnectionClosed: |
| 381 | pass |
| 382 | |
| 383 | logger.info("WebSocket closed for app %s", app_info.tool_name) |
| 384 | |
| 385 | server = await ws_serve( |
| 386 | ws_handler, |
nothing calls this directly
no test coverage detected