from fastapi import WebSocket import json from src.service.service import FaceAuthenticationService class FaceAuthController: def __init__(self): self.auth_service = FaceAuthenticationService() async def handle_register(self, websocket: WebSocket): await websocket.accept() try: while True: data = await websocket.receive_text() response = self.auth_service.process_registration(json.loads(data)) await websocket.send_json(response) except Exception as e: print(f"[INFO] Register WS disconnected: {e}") async def handle_authenticate(self, websocket: WebSocket): await websocket.accept() try: while True: data = await websocket.receive_text() response = self.auth_service.process_authentication(json.loads(data)) await websocket.send_json(response) except Exception as e: print(f"[INFO] Authenticate WS disconnected: {e}")