def __init__(self, baseChannel, serverId=None, dcFileNames=None, dcSuffix='AI', connectMethod=None, threadedNet=None): AstronInternalRepository.__init__( self, baseChannel, serverId=serverId, dcFileNames=dcFileNames, dcSuffix=dcSuffix, connectMethod=connectMethod, threadedNet=threadedNet) self.wantMongo = config.GetBool('want-mongo', False)
def __init__(self, baseChannel, serverId, threadedNet=True): dcFileNames = ['direct.dc', 'toon.dc'] self.GameGlobalsId = 1000 AstronInternalRepository.__init__(self, baseChannel, serverId, dcFileNames=dcFileNames, dcSuffix='AI', connectMethod=self.CM_NET, threadedNet=threadedNet) # Allow some time for other processes. base.setSleep(0.01) self.games = [] self.zoneTable = {} self.hoodArray = [] self.hoods = [] self.managerId = self.allocateChannel() self.toonMgrID = self.allocateChannel() self.zoneAllocator = UniqueIdAllocator(3, 1000000) tcpPort = base.config.GetInt('ai-server-port', 7199) hostname = base.config.GetString('ai-server-host', '127.0.0.1') self.acceptOnce('airConnected', self.connectSuccess) self.connect(hostname, tcpPort)
def __init__(self, args): dcFileNames = ['direct.dc', 'ralph.dc'] self.baseChannel = args.base_channel self.GameGlobalsId = GAME_GLOBALS_ID self.serverId = args.stateserver AstronInternalRepository.__init__(self, self.baseChannel, self.serverId, dcFileNames=dcFileNames, dcSuffix='UD', connectMethod=self.CM_NET, threadedNet=True) # Allow some time for other processes. base.setSleep(0.01) if ':' in args.astron_ip: hostname, tcpPort = args.astron_ip.split(':') else: hostname = args.astron_ip tcpPort = 7190 self.acceptOnce('airConnected', self.connectSuccess) self.connect(hostname, int(tcpPort))
def __init__(self, args): dcFileNames = ['direct.dc', 'ralph.dc'] self.baseChannel = args.base_channel self.GameGlobalsId = GAME_GLOBALS_ID self.serverId = args.stateserver AstronInternalRepository.__init__(self, self.baseChannel, self.serverId, dcFileNames = dcFileNames, dcSuffix = 'UD', connectMethod = self.CM_NET, threadedNet = True) # This is needed so we can generate objects to our World object. self.districtId = self.allocateChannel() self.worldName = args.name # List of generated Ralph objects. self.avatars = [] # Allow some time for other processes. base.setSleep(0.01) if ':' in args.astron_ip: hostname, tcpPort = args.astron_ip.split(':') else: hostname = args.astron_ip tcpPort = 7190 self.acceptOnce('airConnected', self.connectSuccess) self.connect(hostname, int(tcpPort))
def __init__(self, baseChannel, serverId, threadedNet = True): dcFileNames = ['direct.dc', 'tagger.dc'] self.GameGlobalsId = 1000 AstronInternalRepository.__init__(self, baseChannel, serverId, dcFileNames = dcFileNames, dcSuffix = 'AI', connectMethod = self.CM_NET, threadedNet = threadedNet) # Allow some time for other processes. base.setSleep(0.01) taskMgr.setupTaskChain('updateCells', numThreads = 1, threadPriority = TPLow, frameSync = True) taskMgr.doMethodLater(5, self.__checkPosters, 'checkPosters') self.games = [] self.managerId = self.allocateChannel() self.zoneAllocator = UniqueIdAllocator(3, 1000000) tcpPort = base.config.GetInt('ai-server-port', 7190) hostname = base.config.GetString('ai-server-host', '127.0.0.1') self.acceptOnce('airConnected', self.connectSuccess) self.connect(hostname, tcpPort)
def handleDatagram(self, di): msgType = self.getMsgType() if msgType == self.__messenger.msgType: self.__messenger.handle(msgType, di) return AstronInternalRepository.handleDatagram(self, di)
def __init__(self, baseChannel, serverId, dcFileNames, dcSuffix, connectMethod, threadedNet): AstronInternalRepository.__init__(self, baseChannel, serverId=serverId, dcFileNames=dcFileNames, dcSuffix=dcSuffix, connectMethod=connectMethod, threadedNet=threadedNet)
def __init__(self, baseChannel, serverId=None, dcFileNames=None, dcSuffix='AI', connectMethod=None, threadedNet=None): AstronInternalRepository.__init__( self, baseChannel, serverId=serverId, dcFileNames=dcFileNames, dcSuffix=dcSuffix, connectMethod=connectMethod, threadedNet=threadedNet) self.netMessenger.register(0, 'shardStatus') self.netMessenger.register(1, 'queryShardStatus') self.netMessenger.register(2, 'startInvasion') self.netMessenger.register(3, 'stopInvasion')
def __init__(self, baseChannel, serverId=None, dcFileNames=None, dcSuffix='AI', connectMethod=None, threadedNet=None): AstronInternalRepository.__init__(self, baseChannel, serverId, dcFileNames, dcSuffix, connectMethod, threadedNet) self._callbacks = {}
def __init__(self, baseChannel, serverId=None, dcFileNames=None, dcSuffix='AI', connectMethod=None, threadedNet=None): AstronInternalRepository.__init__( self, baseChannel, serverId, dcFileNames, dcSuffix, connectMethod, threadedNet) self._callbacks = {}
def __init__(self): self.baseChannel = 1000000 self.GameGlobalsId = 1000 self.serverId = 4002 self.mongoCli = pymongo.MongoClient('localhost') self.dbCollection = self.mongoCli['jitsu'] AstronInternalRepository.__init__(self, self.baseChannel, self.serverId, dcFileNames=['etc/jitsu.dc'], dcSuffix='UD', connectMethod=self.CM_NET, threadedNet=True)
def startUberDOG(self): notify.info("Starting UberDOG") # UberDOG repository air = AstronInternalRepository(UDChannel, # Repository channel serverId = SSChannel, # Stateserver channel dcFileNames = ["simple_example.dc"], dcSuffix = "UD", connectMethod = AstronInternalRepository.CM_NET) air.connect("127.0.0.1", 7199) air.districtId = air.GameGlobalsId = UDChannel # Create the LoginManager self.login_manager = air.generateGlobalObject(LoginManagerId, 'LoginManager')
def startUberDOG(self): notify.info("Starting UberDOG") # UberDOG repository air = AstronInternalRepository( UDChannel, # Repository channel serverId=SSChannel, # Stateserver channel dcFileNames=["simple_example.dc"], dcSuffix="UD", connectMethod=AstronInternalRepository.CM_NET) air.connect("127.0.0.1", 7199) air.districtId = air.GameGlobalsId = UDChannel # Create the LoginManager self.login_manager = air.generateGlobalObject(LoginManagerId, 'LoginManager')
def __init__(self, baseChannel, serverId=None, dcFileNames=None, dcSuffix='AI', connectMethod=None, threadedNet=None): AstronInternalRepository.__init__(self, baseChannel, serverId=serverId, dcFileNames=dcFileNames, dcSuffix=dcSuffix, connectMethod=connectMethod, threadedNet=threadedNet) self.wantMongo = config.GetBool('want-mongo', False)
def __init__(self, baseChannel, serverId=None, dcFileNames = None, dcSuffix='AI', connectMethod=None, threadedNet=None): AstronInternalRepository.__init__(self, baseChannel, serverId, dcFileNames, dcSuffix, connectMethod, threadedNet) self._callbacks = {} mongourl = mongodb_url.getValue() replicaset = mongodb_replicaset.getValue() db = (urlparse.urlparse(mongourl).path or '/test')[1:] if replicaset: self.mongo = pymongo.MongoClient(mongourl, replicaset=replicaset) else: self.mongo = pymongo.MongoClient(mongourl) self.mongodb = self.mongo[db] self.rpc = RPCClient()
def handleDatagram(self, di): msgType = self.getMsgType() if msgType == self.__messenger.msgType: self.__messenger.handle(msgType, di) return if msgType == CLIENTAGENT_GET_NETWORK_ADDRESS_RESP: context = di.getUint32() remoteIp = di.getString() port = di.getUint16() localIp = di.getString() localPort = di.getUint16() if self.csm: self.csm.completeLogin(context, remoteIp) return AstronInternalRepository.handleDatagram(self, di)
def startAIShard(self): # DO mappings can only be imported once ShowBase has been instantiated. # WTF! FIXME: This has to be fought! No idea how, though... from simple_example import DistributedMaprootAI # AI repository air = AstronInternalRepository(AIChannel, # AI/Shard Channel serverId = SSChannel, # Stateserver Channel dcFileNames = ["simple_example.dc"], connectMethod = AstronInternalRepository.CM_NET) air.connect("127.0.0.1", 7199) air.districtId = air.GameGlobalsId = AIChannel # The map root maproot = DistributedMaprootAI(air) maproot.generateWithRequiredAndId(air.districtId, 0, 1) # No parent / zone # Setting AI channel. air.setAI(maproot.doId, AIChannel) maproot.set_maproot()
def __init__(self, baseChannel, stateserverId): self.GameGlobalsId = 1000 AstronInternalRepository.__init__(self, baseChannel, stateserverId, dcFileNames=['etc/jitsu.dc'], dcSuffix='AI', connectMethod=self.CM_NET, threadedNet=True) self.games = [] self.district = None self.districtId = self.allocateChannel() self.timeManager = None self.matchmaker = None self.game = None self.zoneAllocator = UniqueIdAllocator(3, 1048576) self.acceptOnce('airConnected', self.connectSuccess)
def __init__(self, threadedNet = True): dcFileNames = ['direct.dc', 'toon.dc'] self.baseChannel = 100000000 self.GameGlobalsId = 1000 self.serverId = 4002 AstronInternalRepository.__init__(self, self.baseChannel, self.serverId, dcFileNames = dcFileNames, dcSuffix = 'UD', connectMethod = self.CM_NET, threadedNet = threadedNet) # Allow some time for other processes. base.setSleep(0.01) tcpPort = base.config.GetInt('ai-server-port', 7199) hostname = base.config.GetString('ai-server-host', '127.0.0.1') self.acceptOnce('airConnected', self.connectSuccess) self.connect(hostname, tcpPort)
def __init__(self, threadedNet = True): dcFileNames = ['direct.dc', 'tagger.dc'] self.baseChannel = 100000000 self.GameGlobalsId = 1000 self.serverId = 402000 AstronInternalRepository.__init__(self, self.baseChannel, self.serverId, dcFileNames = dcFileNames, dcSuffix = 'UD', connectMethod = self.CM_NET, threadedNet = threadedNet) # Allow some time for other processes. base.setSleep(0.01) tcpPort = base.config.GetInt('ai-server-port', 7190) hostname = base.config.GetString('ai-server-host', '127.0.0.1') self.acceptOnce('airConnected', self.connectSuccess) self.connect(hostname, tcpPort)
def __init__(self, args): dcFileNames = ['direct.dc', 'ralph.dc'] self.baseChannel = args.base_channel self.GameGlobalsId = GAME_GLOBALS_ID self.serverId = args.stateserver AstronInternalRepository.__init__(self, self.baseChannel, self.serverId, dcFileNames = dcFileNames, dcSuffix = 'UD', connectMethod = self.CM_NET, threadedNet = True) # Allow some time for other processes. base.setSleep(0.01) if ':' in args.astron_ip: hostname, tcpPort = args.astron_ip.split(':') else: hostname = args.astron_ip tcpPort = 7190 self.acceptOnce('airConnected', self.connectSuccess) self.connect(hostname, int(tcpPort))
def readerPollOnce(self): try: return AstronInternalRepository.readerPollOnce(self) except SystemExit as KeyboardInterrupt: raise except Exception as e: if self.getAvatarIdFromSender() > 100000000: dg = PyDatagram() dg.addServerHeader(self.getMsgSender(), self.ourChannel, CLIENTAGENT_EJECT) dg.addUint16(166) dg.addString('You were disconnected to prevent a district reset.') self.send(dg) self.writeServerEvent('INTERNAL-EXCEPTION', self,getAvatarIdFromSender(), self.getAccountIdFromSender, repr(e), traceback.format_exc()) self.notify.warning('INTERNAL-EXCEPTION: {0} ({1})'.format(repr(e), self.getAvatarIdFromSender)) print(traceback.format_exc) sys.exc_clear() return 1
def readerPollOnce(self): try: return AstronInternalRepository.readerPollOnce(self) except (SystemExit, KeyboardInterrupt): raise except Exception as e: if self.getAvatarIdFromSender( ) > 100000000: # If an avatar is sending, boot them dg = PyDatagram() dg.addServerHeader(self.getMsgSender(), self.ourChannel, CLIENTAGENT_EJECT) dg.addUint16(420) dg.addString( 'You were disconnected to prevent a district reset.') self.send(dg) self.writeServerEvent('EXCEPTION-POTENTIAL-CRASH', self.getAvatarIdFromSender(), self.getAccountIdFromSender(), repr(e), traceback.format_exc()) self.notify.warning('EXCEPTION-POTENTIAL-CRASH: %s (%s)' % (repr(e), self.getAvatarIdFromSender())) print traceback.format_exc() sys.exc_clear() import os if os.getenv('DISTRICT_NAME', 'Test Canvas') == "Test Canvas": return 1 from raven import Client from os.path import expanduser errorReporter = Client( 'https://*****:*****@sentry.io/189240' ) errorReporter.tags_context({ 'district_name': os.getenv('DISTRICT_NAME', 'UNDEFINED'), 'AVID_SENDER': self.getAvatarIdFromSender(), 'ACID_SENDER': self.getAccountIdFromSender(), 'homedir': expanduser('~'), 'CRITICAL': 'False' }) errorReporter.captureException() return 1
def readerPollOnce(self): try: return AstronInternalRepository.readerPollOnce(self) except (SystemExit, KeyboardInterrupt): raise except Exception as e: if self.getAvatarIdFromSender( ) > 100000000: # If an avatar is sending, boot them dg = PyDatagram() dg.addServerHeader(self.getMsgSender(), self.ourChannel, CLIENTAGENT_EJECT) dg.addUint16(420) dg.addString( 'You were disconnected to prevent a district reset.') self.send(dg) self.writeServerEvent('EXCEPTION-POTENTIAL-CRASH', self.getAvatarIdFromSender(), self.getAccountIdFromSender(), repr(e), traceback.format_exc()) self.notify.warning('EXCEPTION-POTENTIAL-CRASH: %s (%s)' % (repr(e), self.getAvatarIdFromSender())) print traceback.format_exc() return 1
def startAIShard(self): # DO mappings can only be imported once ShowBase has been instantiated. # WTF! FIXME: This has to be fought! No idea how, though... from simple_example import DistributedMaprootAI # AI repository air = AstronInternalRepository( AIChannel, # AI/Shard Channel serverId=SSChannel, # Stateserver Channel dcFileNames=["simple_example.dc"], connectMethod=AstronInternalRepository.CM_NET) air.connect("127.0.0.1", 7199) air.districtId = air.GameGlobalsId = AIChannel # The map root maproot = DistributedMaprootAI(air) maproot.generateWithRequiredAndId(air.districtId, 0, 1) # No parent / zone # Setting AI channel. air.setAI(maproot.doId, AIChannel) maproot.set_maproot()
def readerPollOnce(self): try: return AstronInternalRepository.readerPollOnce(self) except SystemExit, KeyboardInterrupt: raise
def __init__(self, baseChannel, serverId=None, dcFileNames = None, dcSuffix = 'AI', connectMethod = None, threadedNet = None): if connectMethod is None: connectMethod = self.CM_NATIVE AstronInternalRepository.__init__(self, baseChannel, serverId, dcFileNames, dcSuffix, connectMethod, threadedNet)
def readerPollUntilEmpty(self, task): #try: return AstronInternalRepository.readerPollUntilEmpty(self, task) """
def handleConnected(self): AstronInternalRepository.handleConnected(self)