Fix control+c not working

This commit is contained in:
Ammar Askar 2012-09-12 05:11:58 +05:00
parent 9a715a72b8
commit 9b6a195b6a
2 changed files with 13 additions and 1 deletions

View File

@ -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 == ""):

View File

@ -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, "")