def sendMessage(self, msg): self.out.println(str(msg)) response = self.in.readLine() if response is None: # abort abort abort exit(1) decoded = Message.decode(response) return decoded.msgData # empty string or hash
def handle(self): while not self.kill and not self.socket.isClosed(): data = self.in.readLine() if data is None: self.kill = True break msg = Message.decode(data) msgType = msg.msgType msgData = msg.msgData handle = self.handlers[msgType](msgData) print data, '->', msg ack = Ack(handle) self.out.println(str(ack)) # clean up self.connectionTrack.deleteAllEvents() self.server.deleteConnection(self.connectionTrack) self.socket.close()