Migrate most of frontend callServerMethod usage over to websocket

This commit is contained in:
AAGaming
2023-08-05 01:11:43 -04:00
committed by marios8543
parent cfb6fe69e3
commit 34d1a34b10
14 changed files with 162 additions and 160 deletions
+3 -2
View File
@@ -79,7 +79,7 @@ class WSRouter:
match data["type"]:
case MessageType.CALL.value:
# do stuff with the message
if self.routes[data["route"]]:
if data["route"] in self.routes:
try:
res = await self.routes[data["route"]](*data["args"])
await self.write({"type": MessageType.REPLY.value, "id": data["id"], "result": res})
@@ -87,7 +87,8 @@ class WSRouter:
except:
await self.write({"type": MessageType.ERROR.value, "id": data["id"], "error": format_exc()})
else:
await self.write({"type": MessageType.ERROR.value, "id": data["id"], "error": "Route does not exist."})
# Dunno why but fstring doesnt work here
await self.write({"type": MessageType.ERROR.value, "id": data["id"], "error": "Route " + data["route"] + " does not exist."})
case MessageType.REPLY.value:
if self.running_calls[data["id"]]:
self.running_calls[data["id"]].set_result(data["result"])