feat(emulator): now using match structure, cleaner
This commit is contained in:
parent
edd608b233
commit
640c760ca0
|
@ -106,15 +106,13 @@ def state_manager(loop: asyncio.AbstractEventLoop):
|
||||||
while True:
|
while True:
|
||||||
for message in ps.listen():
|
for message in ps.listen():
|
||||||
if message["type"] == "message":
|
if message["type"] == "message":
|
||||||
data = message["data"].decode("utf-8")
|
match message["data"].decode("utf-8").split(":"):
|
||||||
|
case ["save"]:
|
||||||
# TODO: voir si plus clean possible ?
|
|
||||||
# TODO: dev dans un docker ?
|
|
||||||
|
|
||||||
if data == "save":
|
|
||||||
asyncio.ensure_future(utils.save(core), loop=loop)
|
asyncio.ensure_future(utils.save(core), loop=loop)
|
||||||
elif data.startswith("load:"):
|
case ["load", filename]:
|
||||||
asyncio.ensure_future(utils.load(core, data.removeprefix("load:")), loop=loop)
|
asyncio.ensure_future(utils.load(core, filename), loop=loop)
|
||||||
|
case _:
|
||||||
|
print(f"Command not understood: {message}")
|
||||||
|
|
||||||
|
|
||||||
async def emulator():
|
async def emulator():
|
||||||
|
|
Loading…
Reference in a new issue