From c0eb8ed32d53030de5b75b49a8e0f64e7c4a05ff Mon Sep 17 00:00:00 2001 From: troido Date: Wed, 18 Apr 2018 12:43:19 +0200 Subject: client is now threadsafe; closing can now show messages --- asciifarm/client/start.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'asciifarm/client/start.py') 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) -- cgit