File size: 1,062 Bytes
5a52952
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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}")