From 30c83951a4a949c0f157f37c720a0afdabb16d6a Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Thu, 14 May 2020 12:18:40 +0200 Subject: [PATCH] Updated Link example --- Examples/Link.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Examples/Link.py b/Examples/Link.py index d05d716..a1ef7ac 100644 --- a/Examples/Link.py +++ b/Examples/Link.py @@ -149,19 +149,23 @@ def client_loop(): should_quit = False while not should_quit: - print("> ", end=" ") - text = input() + try: + print("> ", end=" ") + text = input() - # Check if we should quit the example - if text == "quit" or text == "q" or text == "exit": + # Check if we should quit the example + if text == "quit" or text == "q" or text == "exit": + should_quit = True + server_link.teardown() + + # If not, send the entered text over the link + if text != "": + data = text.encode("utf-8") + RNS.Packet(server_link, data).send() + except Exception as e: should_quit = True server_link.teardown() - # If not, send the entered text over the link - if text != "": - data = text.encode("utf-8") - RNS.Packet(server_link, data).send() - # This function is called when a link # has been established with the server def link_established(link):