diff options
-rw-r--r-- | game/04_init.rpy | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/game/04_init.rpy b/game/04_init.rpy index 74e0a97..f7c0478 100644 --- a/game/04_init.rpy +++ b/game/04_init.rpy @@ -170,13 +170,30 @@ init python: def supervisor(use_ssl): global ws stdout(_("Opening new socket...")) - if use_ssl: - ws = GameClient("wss://"+HOST+":61000") - else: - ws = GameClient("ws://"+HOST+":61000") - ws.connect() - renpy.invoke_in_thread(ws.run_forever) # May be problematic - stdout("Connection established!") - # The supervisor module is now uneeded as thread was cast + done=False + while not done: + try: + if use_ssl: + ws = GameClient("wss://"+HOST+":61000") + else: + ws = GameClient("ws://"+HOST+":61000") + ws.connect() + # May be problematic. + # Specially if exception is uncaught + renpy.invoke_in_thread(ws.run_forever) + done=True + stdout("Connection established!") + except: + traceback.print_exc() + stdout("CONNECTION FAILED, PLEASE TRY AGAIN") + display_msgbox("Connection Error. Please check internet connection.") + sdelay(10.0) # It will keep trying again, ever and ever. + # FIXME: sdelay(), with fixed time is a bad idea. + # We should allow user to retry (no hard pause) + # And we should scale up the time between attempts + # Just in case server is flooded, we do not want to DoS it =/ + # (And incur in firewall's wrath while at that!) + + # The supervisor module is now uneeded as thread was cast, so return return |