Better naming

This commit is contained in:
ben 2022-11-23 23:35:02 +00:00
parent cea4f9350c
commit fde128e961

View File

@ -720,23 +720,23 @@ class websocketConnectionManager:
await connection.send_text(message)
manager = websocketConnectionManager()
websocketManager = websocketConnectionManager()
@core_app.websocket("/api/v1/ws/{item_id}")
async def websocket_connect(websocket: WebSocket, item_id: str):
await manager.connect(websocket, item_id)
await websocketManager.connect(websocket, item_id)
try:
while True:
data = await websocket.receive_text()
except WebSocketDisconnect:
manager.disconnect(websocket)
websocketManager.disconnect(websocket)
@core_app.post("/api/v1/ws/{item_id}")
async def websocket_update(item_id: str, data: str):
try:
await updater(item_id, data)
await websocketUpdater(item_id, data)
return {"sent": True, "data": data}
except:
return {"sent": False, "data": data}
@ -745,11 +745,11 @@ async def websocket_update(item_id: str, data: str):
@core_app.get("/api/v1/ws/{item_id}/{data}")
async def websocket_update(item_id: str, data: str):
try:
await updater(item_id, data)
await websocketUpdater(item_id, data)
return {"sent": True, "data": data}
except:
return {"sent": False, "data": data}
async def updater(item_id, data):
return await manager.send_data(f"{data}", item_id)
async def websocketUpdater(item_id, data):
return await websocketManager.send_data(f"{data}", item_id)