SNIClient: make address optional for multi-snes

This commit is contained in:
Fabian Dill 2022-02-20 04:16:34 +01:00
parent 4f47709d32
commit e94b99da65
1 changed files with 6 additions and 6 deletions

View File

@ -56,7 +56,8 @@ class LttPCommandProcessor(ClientCommandProcessor):
@mark_raw @mark_raw
def _cmd_snes(self, snes_options: str = "") -> bool: def _cmd_snes(self, snes_options: str = "") -> bool:
"""Connect to a snes. Optionally include network address of a snes to connect to, """Connect to a snes. Optionally include network address of a snes to connect to,
otherwise show available devices; and a SNES device number if more than one SNES is detected""" otherwise show available devices; and a SNES device number if more than one SNES is detected.
Examples: "/snes", "/snes 1", "/snes localhost:8080 1" """
snes_address = self.ctx.snes_address snes_address = self.ctx.snes_address
snes_device_number = -1 snes_device_number = -1
@ -65,13 +66,12 @@ class LttPCommandProcessor(ClientCommandProcessor):
num_options = len(options) num_options = len(options)
if num_options > 0: if num_options > 0:
snes_address = options[0] snes_device_number = int(options[0])
if num_options > 1: if num_options > 1:
try: snes_address = options[0]
snes_device_number = int(options[1]) snes_device_number = int(options[1])
except:
pass
self.ctx.snes_reconnect_address = None self.ctx.snes_reconnect_address = None
asyncio.create_task(snes_connect(self.ctx, snes_address, snes_device_number), name="SNES Connect") asyncio.create_task(snes_connect(self.ctx, snes_address, snes_device_number), name="SNES Connect")