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) await connection.send_text(message)
manager = websocketConnectionManager() websocketManager = websocketConnectionManager()
@core_app.websocket("/api/v1/ws/{item_id}") @core_app.websocket("/api/v1/ws/{item_id}")
async def websocket_connect(websocket: WebSocket, item_id: str): async def websocket_connect(websocket: WebSocket, item_id: str):
await manager.connect(websocket, item_id) await websocketManager.connect(websocket, item_id)
try: try:
while True: while True:
data = await websocket.receive_text() data = await websocket.receive_text()
except WebSocketDisconnect: except WebSocketDisconnect:
manager.disconnect(websocket) websocketManager.disconnect(websocket)
@core_app.post("/api/v1/ws/{item_id}") @core_app.post("/api/v1/ws/{item_id}")
async def websocket_update(item_id: str, data: str): async def websocket_update(item_id: str, data: str):
try: try:
await updater(item_id, data) await websocketUpdater(item_id, data)
return {"sent": True, "data": data} return {"sent": True, "data": data}
except: except:
return {"sent": False, "data": data} 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}") @core_app.get("/api/v1/ws/{item_id}/{data}")
async def websocket_update(item_id: str, data: str): async def websocket_update(item_id: str, data: str):
try: try:
await updater(item_id, data) await websocketUpdater(item_id, data)
return {"sent": True, "data": data} return {"sent": True, "data": data}
except: except:
return {"sent": False, "data": data} return {"sent": False, "data": data}
async def updater(item_id, data): async def websocketUpdater(item_id, data):
return await manager.send_data(f"{data}", item_id) return await websocketManager.send_data(f"{data}", item_id)