改进项目结构

This commit is contained in:
2025-03-14 15:44:41 +08:00
parent 8478b4a102
commit 9e79fb6a6d
95 changed files with 13745 additions and 64 deletions

View File

@ -15,6 +15,8 @@ class SocketManager:
self.rooms[room].remove(websocket)
if len(self.rooms[room]) == 0:
del self.rooms[room]
if room.startswith('detect_rtsp_'):
print()
async def broadcast_to_room(self, room: str, message: str, exclude_websocket: WebSocket = None):
if room in self.rooms:
@ -30,8 +32,16 @@ class SocketManager:
for ws in self.rooms[room]:
try:
await ws.send_text(message)
except:
await self.remove_from_room(room, ws)
except Exception as e:
print(e)
async def send_stream_to_room(self, room: str, message):
if room in self.rooms:
for ws in self.rooms[room]:
try:
await ws.send_bytes(message)
except Exception as e:
print(e)
room_manager = SocketManager()