def startClientThroughNAT(self, serverIP, facilitatorAddress): # all NAT stuff is pretty much spaghetti code =/... better work that out some day... self.isServer = False ege.externalStartClient(serverIP, True, facilitatorAddress) connected = False for i in range(100): sleep(0.1) packet = ege.receiveData() if packet: print packet if packet and packet['type'] == 'connected': connected = True self.start() break return connected
def startClientDirectConnect(self, serverIP): self.isServer = False ege.externalStartClient(serverIP, False) # ege.externalStartClient(serverIP, False) connected = False for i in range(100): sleep(0.1) packet = ege.receiveData() if packet: print packet if packet and packet['type'] == 'connected': connected = True self.start() break return connected
answer = raw_input() if answer.upper() == 'S': isServer = True elif answer.upper() == 'C': isServer = False else: raise Exception("Invalid input:", answer, ", must be either 'S' or 'C'") if isServer: ege.externalStartServer(MAX_NO_OF_PLAYERS, False, '') else: ege.externalStartClient('127.0.0.1', False) done = False try: while not done: packet = ege.receiveData() if packet: print packet if packet['type'] == 'connected' or packet['type'] == 'incomingConnection': game.main() done = True finally: ege.externalCloseAll()