This commit is contained in:
Fabian Dill
2020-02-22 18:04:35 +01:00
parent b755e9a9ee
commit 09fba10a53
3 changed files with 52 additions and 21 deletions

View File

@@ -14,6 +14,10 @@ ModuleUpdate.update()
import colorama
import websockets
import aioconsole
try:
import tqdm
except:
tqdm = None
import Items
import Regions
@@ -74,7 +78,7 @@ def color(text, *args):
return color_code(*args) + text + color_code('reset')
RECONNECT_DELAY = 30
RECONNECT_DELAY = 5
ROM_START = 0x000000
WRAM_START = 0xF50000
@@ -415,7 +419,11 @@ async def snes_connect(ctx : Context, address):
asyncio.create_task(snes_autoreconnect(ctx))
async def snes_autoreconnect(ctx: Context):
await asyncio.sleep(RECONNECT_DELAY)
if tqdm:
for _ in tqdm.trange(100, unit='%', leave=False):
await asyncio.sleep(RECONNECT_DELAY/100)
else:
await asyncio.sleep(RECONNECT_DELAY)
if ctx.snes_reconnect_address and ctx.snes_socket is None:
await snes_connect(ctx, ctx.snes_reconnect_address)
@@ -601,7 +609,11 @@ async def server_loop(ctx : Context, address = None):
asyncio.create_task(server_autoreconnect(ctx))
async def server_autoreconnect(ctx: Context):
await asyncio.sleep(RECONNECT_DELAY)
if tqdm:
for _ in tqdm.trange(100, unit='%', leave=False):
await asyncio.sleep(RECONNECT_DELAY/100)
else:
await asyncio.sleep(RECONNECT_DELAY)
if ctx.server_address and ctx.server_task is None:
ctx.server_task = asyncio.create_task(server_loop(ctx))