diff options
author | Jesusaves <cpntb1@ymail.com> | 2020-12-18 23:24:52 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2020-12-18 23:24:52 -0300 |
commit | 62167b8faf8187baa4ec2c5fc2a87910712a8ed3 (patch) | |
tree | 5d6cd3c0d4da9a2ad230e8cea855b7dc16d88962 /game | |
parent | 4d16b944d6a9db15f6cf36e3989d751ab47af5c7 (diff) | |
download | client-62167b8faf8187baa4ec2c5fc2a87910712a8ed3.tar.gz client-62167b8faf8187baa4ec2c5fc2a87910712a8ed3.tar.bz2 client-62167b8faf8187baa4ec2c5fc2a87910712a8ed3.tar.xz client-62167b8faf8187baa4ec2c5fc2a87910712a8ed3.zip |
When facing a connection error, do not hang eternally - try again.
Diffstat (limited to 'game')
-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 |