diff options
| author | troido <troido@hotmail.com> | 2018-04-18 12:43:19 +0200 |
|---|---|---|
| committer | troido <troido@hotmail.com> | 2018-04-18 12:43:19 +0200 |
| commit | c0eb8ed32d53030de5b75b49a8e0f64e7c4a05ff (patch) | |
| tree | 7213e87795d631f7177c7a930f3a86a8143a47ff /asciifarm/client/start.py | |
| parent | d4a2a5742f41234e5bf2dafb7e3bcea8c24bb712 (diff) | |
client is now threadsafe; closing can now show messages
Diffstat (limited to 'asciifarm/client/start.py')
| -rw-r--r-- | asciifarm/client/start.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/asciifarm/client/start.py b/asciifarm/client/start.py index 0a6cfa4..3e24e4a 100644 --- a/asciifarm/client/start.py +++ b/asciifarm/client/start.py @@ -23,19 +23,19 @@ def main(name, socketType, address, keybindings, characters, colours=False, logf print("ERROR: Could not connect to server.\nAre you sure that the server is running and that you're connecting to the right address?", file=sys.stderr) return - caught_ctrl_c = False + closeMessage = None def start(stdscr): display = Display(stdscr, characters, colours) client = Client(stdscr, display, name, connection, keybindings, logfile) - nonlocal caught_ctrl_c try: client.start() except KeyboardInterrupt: - client.keepAlive = False - caught_ctrl_c = True + client.close("^C caught, goodbye") + nonlocal closeMessage + closeMessage = client.closeMessage curses.wrapper(start) - if caught_ctrl_c: - print('^C caught, goodbye!') + if closeMessage: + print(closeMessage, file=sys.stderr) |
