1
0
mirror of https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git synced 2025-08-14 00:25:46 +02:00

add websockets suppor3

This commit is contained in:
MoonTestUse1
2025-01-05 01:54:17 +06:00
parent a81310d0e7
commit 65d9eddb53
5 changed files with 75 additions and 14 deletions

View File

@@ -2,6 +2,7 @@ from fastapi import WebSocket
from typing import Dict, List
import json
import logging
import asyncio
logger = logging.getLogger(__name__)
@@ -58,4 +59,12 @@ class NotificationManager:
for connection in disconnected:
self.disconnect(connection, "employee")
async def handle_ping(self, websocket: WebSocket):
"""Обработка ping сообщений"""
try:
await websocket.send_json({"type": "pong"})
logger.debug("Sent pong response")
except Exception as e:
logger.error(f"Error sending pong: {e}")
notification_manager = NotificationManager()