eksplicit mapping af envs
This commit is contained in:
16
backend/app/api/ws.py
Normal file
16
backend/app/api/ws.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from fastapi import APIRouter, WebSocket, WebSocketDisconnect
|
||||
|
||||
from app.services.ws_manager import manager
|
||||
|
||||
router = APIRouter(tags=["websocket"])
|
||||
|
||||
|
||||
@router.websocket("/ws/{ble_token}")
|
||||
async def websocket_endpoint(websocket: WebSocket, ble_token: str) -> None:
|
||||
await manager.connect(ble_token, websocket)
|
||||
try:
|
||||
while True:
|
||||
# Keep the connection alive; nudges are pushed server-side.
|
||||
await websocket.receive_text()
|
||||
except WebSocketDisconnect:
|
||||
manager.disconnect(ble_token)
|
||||
Reference in New Issue
Block a user