def makepacket(ent): assert ent.entID is not None return str( GameProtocol.SpawnEnt(asUnixPath(ent.typeInfo.typePath), ent.scriptname, ent.entID, ent.location.x, ent.location.y, ent.location.z, ent.q4.x, ent.q4.y, ent.q4.z, ent.q4.w))
def onReceive(self, event): msg = GameProtocol.read(event.packet.data) if msg.name == 'SpawnEnt': #print msg self.world.netSpawnEnt(msg) elif msg.name == 'MoveEnt': #print event.packet self.world.netMoveEnt(msg) elif msg.name == 'MoveActor': self.world.netMoveActor(msg)
def onReceive(self, event): msg = GameProtocol.read( event.packet.data ) if msg.name == 'SpawnEnt': #print msg self.world.netSpawnEnt( msg ) elif msg.name == 'MoveEnt': #print event.packet self.world.netMoveEnt( msg ) elif msg.name == 'MoveActor': self.world.netMoveActor(msg)
def makemovepacket(ent): #ent.velocity actually has to make a foreign function #call to C to get the velocity, so we only want to call it once ev = ent.velocity return str(GameProtocol.MoveEnt(ent.entID, ent.location.x, ent.location.y, ent.location.z, ent.q4.x, ent.q4.y, ent.q4.z, ent.q4.w, ev.x, ev.y, ev.z ))
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): print "Received Message", GameProtocol.read(event.packet.data)
def onReceive(self, connection, event): #relay print "Received message on connection:", connection msg = GameProtocol.read(event.packet.data) print msg
def makeUpdatePacket(self): return str( GameProtocol.MoveEnt(self.entID, self.location.x, self.location.y, self.location.z, self.q4.x, self.q4.y, self.q4.z, self.q4.w, 0, 0, 0))
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
prompt = True automatch = True # Build the socket and create the game protocol object port = sys.argv[2] host = sys.argv[1] s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_address = (str(host), int(port)) try: s.connect(server_address) except: print('could not connected to server') not_done = False lock = threading.Lock() p = GameProtocol(s, server_address) # dict for executing commands. pro = { 'games': p.GAMES, 'place': p.PLACE, 'exit': p.EXIT, 'play': p.PLAY, 'who': p.WHO, 'login': p.LOGIN, 'observe': p.OBSERVE, 'unobserve': p.UNOBSERVE, 'comment': p.COMMENT, 'automatch': p.automatch, 'prompt': changePrompt }
def onConnect(self, event): print "Connected to:", event.peer.address self.send(GameProtocol.SetName(name))
def makeUpdatePacket(self): return str( GameProtocol.MoveActor(self.entID, self.location.x, self.location.y, self.location.z, self.yaw, self.pitch))
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
def onReceive(self, connection, event): #relay print "Received message on connection:", connection msg = GameProtocol.read( event.packet.data ) print msg