def processNetMessage(self, data): if data['type'] == "position": self.parseEnData(data) #has server specific routine inside if data['type'] == "time": self.gameTime = data['time'][1:len(data['time'])] #time data is buffered with a character so we can start it with a 0 if not self.server and data['type'] == "effect": #client specific #should have position, id, etc PEG_mainLoop.mainLoop().entityDict['EffectMenu'].addEffect(PEG_effects.quickEffect( int(data['id']), Vector2d(int(data['x']),int(data['y'])), (int(data['r']),int(data['g']),int(data['b'])), int(data['radius']), int(data['sides']) )) if not self.server and data['type'] == "state": #client specific menu = PEG_mainLoop.mainLoop().entityDict["MenuEn"] if data['state'] == "gameover": menu.gameover = True menu.winner = data['winner'] menu.Ascore = data['Ateam'] menu.Bscore = data['Bteam'] elif data['state'] == "starting": menu.gameover = False if self.server and 'relay' in data: #server specific del data['relay'] self.mgr.send(self.makeDefaultMessage(data)) #print "relayed", data if self.server and data['type'] == "event": #server specific if data['event'] == "arduino": if 'ThePSource' in self.enDict: self.processArduinoEvent(data) #FIXK THIS if self.server and data['type'] == "init": #server specific try: m[1].name = data['name'] print data['name'], " client is set" except: pass #now we check if all clients have been identified #this is kind of bad because we don't wait for extra clients to join, too bad #add maybe a 10 second grace period flag = True self.mgr.clntListlock.acquire() for e in self.mgr.clntList: if e.name == None: flag = False break self.mgr.clntListlock.release()
def processNetMessage(self, data): if data["type"] == "position": # We only update entities after one has been idnetififed if self.server or self.color: self.parseEnData(data) # has server specific routine inside if data["type"] == "time": self.gameTime = data["time"] if not self.server and data["type"] == "effect": # client specific # should have position, id, etc print "got effect from serva", data PEG_mainLoop.mainLoop().entityDict["EffectMenu"].addEffect( PEG_effects.quickEffect( int(data["id"]), Vector2d(int(data["x"]), int(data["y"])), (int(data["r"]), int(data["g"]), int(data["b"])), int(data["radius"]), int(data["sides"]), ) ) if not self.server and data["type"] == "state": # client specific menu = PEG_mainLoop.mainLoop().entityDict["MenuEn"] if data["state"] == "gameover": menu.gameover = True menu.winner = data["winner"] menu.Ascore = data["Ateam"] menu.Bscore = data["Bteam"] elif data["state"] == "starting": menu.gameover = False if self.server and "relay" in data: # server specific del data["relay"] self.send(self.makeDefaultMessage(data)) # print "relayed", data if self.server and data["type"] == "event": # server specific if data["event"] == "arduino": if "ThePSource" in self.enDict: self.processArduinoEvent(data)
def processNetMessage(self, data): if data['type'] == "position": #We only update entities after one has been idnetififed if self.server or self.color: self.parseEnData(data) #has server specific routine inside if data['type'] == "time": self.gameTime = data['time'] if not self.server and data['type'] == "effect": #client specific #should have position, id, etc print "got effect from serva", data PEG_mainLoop.mainLoop().entityDict['EffectMenu'].addEffect(PEG_effects.quickEffect( int(data['id']), Vector2d(int(data['x']),int(data['y'])), (int(data['r']),int(data['g']),int(data['b'])), int(data['radius']), int(data['sides']) )) if not self.server and data['type'] == "state": #client specific menu = PEG_mainLoop.mainLoop().entityDict["MenuEn"] if data['state'] == "gameover": menu.gameover = True menu.winner = data['winner'] menu.Ascore = data['Ateam'] menu.Bscore = data['Bteam'] elif data['state'] == "starting": menu.gameover = False if self.server and 'relay' in data: #server specific del data['relay'] self.send(self.makeDefaultMessage(data)) #print "relayed", data if self.server and data['type'] == "event": #server specific if data['event'] == "arduino": if 'ThePSource' in self.enDict: self.processArduinoEvent(data)