def Run(self): """ The program body for the thread. This is not called directly, but is launched indirectly using the C{Start} member. """ leftovers = "" while self.keepListening: try: pmessage, leftovers = network.recvmessage(self.client.sock, leftovers) if pmessage == None: print "ListenerThread: connection closed; terminating" # FIXME: change client status to disconnected, notify GUI self.keepListening = False break except: print "ListenerThread: caught exception; terminating: " print " ", sys.exc_info() self.keepListening = False break else: message = cerealizer.loads(pmessage) if message["type"] == "gm": # Only place Game Messages ('gm') on the queue. self.queue.put((self.client, message)) elif message["type"] == "sync": # Place sync messages on the client's sync queue (client is # responding to server's sync message) self.client.syncQueue.put(message) self.postEvent(self.client, message) # Thread is terminating. self.postEvent(self.client, {"type": "disconnect"})
def Run(self): try: leftovers = "" while self.keepListening: data, leftovers = network.recvmessage(self.communicator.sock, leftovers) if data == None: print "ListenerThread: connection closed; terminating" self.keepListening = False break message = cerealizer.loads(data) if message["type"] == "sync": # Server sent a sync message; send back a reply immediately # with our wall-clock time self.communicator.send({"type": "sync", "ct": time.time()}) else: self.communicator.postEvent(message) except: print "ListenerThread.Run(): caught exception:" traceback.print_exc(file=sys.stdout) # Thread is terminating. self.communicator.postEvent({"type": "disconnect"})
def Run(self): """ The program body for the thread. This is not called directly, but is launched indirectly using the C{Start} member. """ leftovers = '' while self.keepListening: try: pmessage, leftovers = network.recvmessage( self.client.sock, leftovers) if pmessage == None: print "ListenerThread: connection closed; terminating" # FIXME: change client status to disconnected, notify GUI self.keepListening = False break except: print "ListenerThread: caught exception; terminating: " print " ", sys.exc_info() self.keepListening = False break else: message = cerealizer.loads(pmessage) if message['type'] == 'gm': # Only place Game Messages ('gm') on the queue. self.queue.put((self.client, message)) elif message['type'] == 'sync': # Place sync messages on the client's sync queue (client is # responding to server's sync message) self.client.syncQueue.put(message) self.postEvent(self.client, message) # Thread is terminating. self.postEvent(self.client, {'type': 'disconnect'})
def Run(self): try: leftovers = '' while self.keepListening: data, leftovers = network.recvmessage(self.communicator.sock, leftovers) if data == None: print "ListenerThread: connection closed; terminating" self.keepListening = False break message = cerealizer.loads(data) if message['type'] == 'sync': # Server sent a sync message; send back a reply immediately # with our wall-clock time self.communicator.send({'type': 'sync', 'ct': time.time()}) else: self.communicator.postEvent(message) except: print "ListenerThread.Run(): caught exception:" traceback.print_exc(file=sys.stdout) # Thread is terminating. self.communicator.postEvent({'type': 'disconnect'})