diff --git a/networking/NetworkManager.py b/networking/NetworkManager.py index c93bcb2..060d558 100644 --- a/networking/NetworkManager.py +++ b/networking/NetworkManager.py @@ -69,6 +69,10 @@ class ServerConnection(threading.Thread): self.NoGUI = False self.window = window + def disconnect(self): + self.listener.kill = True + self.socket.close() + def setWindow(self, window): self.window = window @@ -214,6 +218,7 @@ class PacketListener(threading.Thread): self.FileObject = FileObject self.window = window self.encryptedConnection = False + self.kill = False def enableEncryption(self): #Create an AES cipher from the previously obtained public key @@ -234,6 +239,8 @@ class PacketListener(threading.Thread): def run(self): while True: + if (self.kill): + break try: response = self.FileObject.read(1) if (response == ""): diff --git a/start.py b/start.py index a1163ab..2a355fc 100644 --- a/start.py +++ b/start.py @@ -121,7 +121,12 @@ if __name__ == "__main__": port = 25565 connection = NetworkManager.ServerConnection(None, derp['Username'], passwd, sessionid, host, port) connection.start() - raw_input() + while True: + try: + raw_input() + except KeyboardInterrupt, e: + connection.disconnect() + sys.exit(1) else: app = wx.PySimpleApp() Login = GUI.MainFrame(None, -1, "")