first commit
This commit is contained in:
commit
4b98219bf7
144 changed files with 31561 additions and 0 deletions
16
backend/api/routes/ws.py
Normal file
16
backend/api/routes/ws.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
from fastapi import APIRouter, WebSocket, WebSocketDisconnect
|
||||
from services.ws_manager import manager
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.websocket("/ws")
|
||||
async def websocket_endpoint(ws: WebSocket):
|
||||
await manager.connect(ws)
|
||||
try:
|
||||
while True:
|
||||
# We only push from server → client.
|
||||
# receive_text() keeps the connection alive.
|
||||
await ws.receive_text()
|
||||
except WebSocketDisconnect:
|
||||
manager.disconnect(ws)
|
||||
Loading…
Add table
Add a link
Reference in a new issue