def simpletest(): global name print "Name?" name = sys.stdin.readline(32) ch = ChatClient('127.0.0.1', 1234) ch.runUpdateThread() try: done = False while not done: input = sys.stdin.readline() if input.strip() == 'quit': ch.disconnect() done = True else: ch.send(GameProtocol.ChatMessage(input)) except KeyboardInterrupt: print "Quitting..." ch.disconnect() done = True ch.stopUpdateThread()
def onReceive(self, event): msg = GameProtocol.read(event.packet.data) if 'message' in msg.keys(): self.sendToAll(GameProtocol.ChatMessage(msg['message'])) print event.peer.address, msg