This commit is contained in:
Waylon S. Walker 2024-12-11 09:17:38 -06:00
parent a70c24398a
commit e181f57a91
30 changed files with 2458 additions and 197 deletions

View file

@ -0,0 +1,22 @@
from fastapi import WebSocket
class ConnectionManager:
"""Class defining socket events"""
def __init__(self):
"""init method, keeping track of connections"""
self.active_connections = []
async def connect(self, websocket: WebSocket):
"""connect event"""
await websocket.accept()
self.active_connections.append(websocket)
async def send_personal_message(self, message: str, websocket: WebSocket):
"""Direct Message"""
await websocket.send_text(message)
def disconnect(self, websocket: WebSocket):
"""disconnect event"""
self.active_connections.remove(websocket)