fixed many remaining bugs in testbench webserver, should be ready for use.

This commit is contained in:
UpstreamData
2022-04-14 18:17:23 -06:00
parent 3a560472e6
commit eb5a00b706
8 changed files with 79 additions and 45 deletions

View File

@@ -7,6 +7,7 @@ from tools.web_testbench._network import miner_network
class ConnectionManager:
_instance = None
_connections = []
lit_miners = []
def __new__(cls):
if not cls._instance:
@@ -16,16 +17,17 @@ class ConnectionManager:
async def connect(self, websocket: WebSocket):
await websocket.accept()
miners = []
print(ConnectionManager.lit_miners)
for host in miner_network.hosts():
if host in MinerFactory().miners.keys():
if str(host) in ConnectionManager.lit_miners:
miners.append(
{
"IP": str(host),
"Light_On": await MinerFactory().miners[host].get_light(),
"Light_On": True,
}
)
else:
miners.append({"IP": str(host), "Light_On": None})
miners.append({"IP": str(host), "Light_On": False})
await websocket.send_json({"miners": miners})
ConnectionManager._connections.append(websocket)