def handleConnected(self):
        rootObj = DistributedDirectoryAI(self)
        rootObj.generateWithRequiredAndId(self.getGameDoId(), 0, 0)

        self.apiMgr = ShardAPIManagerUD(self)
        self.apiMgr.generateWithRequiredAndId(100001, 0, 0)

        self.banMgr = BanManagerUD(self)
        self.banMgr.generateWithRequiredAndId(100002, 0, 0)

        self.createGlobals()

        self.apiWS = ShardAPIWebServer.start(self.apiMgr)
    def handleConnected(self):
        rootObj = DistributedDirectoryAI(self)
        rootObj.generateWithRequiredAndId(self.getGameDoId(), 0, 0)
        
        self.apiMgr = ShardAPIManagerUD(self)
        self.apiMgr.generateWithRequiredAndId(100001, 0, 0)
        
        self.banMgr = BanManagerUD(self)
        self.banMgr.generateWithRequiredAndId(100002, 0, 0)

        self.createGlobals()
        
        self.apiWS = ShardAPIWebServer.start(self.apiMgr)
class ToontownUberRepository(ToontownInternalRepository):
    def __init__(self, baseChannel, serverId):
        ToontownInternalRepository.__init__(self,
                                            baseChannel,
                                            serverId,
                                            dcSuffix='UD')
        self.__loader = DNALoader.DNALoader()
        self.__dnaMap = {}

    def getDnaStore(self, zoneId):
        if zoneId in self.__dnaMap:
            return self.__dnaMap[zoneId]

        x = DNAStorage.DNAStorage()
        filename = self.genDNAFileName(zoneId)

        print 'Loading dna file', self.genDNAFileName(zoneId)
        self.loadDNAFileAI(x, filename)

        self.__dnaMap[zoneId] = x

        return x

    def handleConnected(self):
        rootObj = DistributedDirectoryAI(self)
        rootObj.generateWithRequiredAndId(self.getGameDoId(), 0, 0)

        self.apiMgr = ShardAPIManagerUD(self)
        self.apiMgr.generateWithRequiredAndId(100001, 0, 0)

        self.banMgr = BanManagerUD(self)
        self.banMgr.generateWithRequiredAndId(100002, 0, 0)

        self.createGlobals()

        self.apiWS = ShardAPIWebServer.start(self.apiMgr)

    def createGlobals(self):
        self.csm = simbase.air.generateGlobalObject(
            OTP_DO_ID_CLIENT_SERVICES_MANAGER, 'ClientServicesManager')

        self.chatAgent = simbase.air.generateGlobalObject(
            OTP_DO_ID_CHAT_MANAGER, 'ChatAgent')

        self.friendsManager = simbase.air.generateGlobalObject(
            OTP_DO_ID_TT_FRIENDS_MANAGER, 'TTFriendsManager')

        self.globalPartyMgr = simbase.air.generateGlobalObject(
            OTP_DO_ID_GLOBAL_PARTY_MANAGER, 'GlobalPartyManager')

        if config.GetBool('want-top-toons', True):
            if OTP_DO_ID_TOONTOWN_TOP_TOONS_MGR == 100003:
                self.topToonsMgr = DistributedTopToonsManagerUD(self)
                self.topToonsMgr.generateWithRequiredAndId(
                    100003, self.getGameDoId(), 2)

                dg = PyDatagram()
                dg.addServerHeader(100003, self.ourChannel,
                                   STATESERVER_OBJECT_SET_AI)
                dg.addChannel(self.ourChannel)
                self.send(dg)

            else:
                self.topToonsMgr = self.generateGlobalObject(
                    OTP_DO_ID_TOONTOWN_TOP_TOONS_MGR,
                    'DistributedTopToonsManager')

    def genDNAFileName(self, zoneId):
        zoneId = ZoneUtil.getCanonicalZoneId(zoneId)
        hoodId = ZoneUtil.getCanonicalHoodId(zoneId)
        hood = ToontownGlobals.dnaMap[hoodId]
        if hoodId == zoneId:
            zoneId = 'sz'
            phase = ToontownGlobals.phaseMap[hoodId]
        else:
            phase = ToontownGlobals.streetPhaseMap[hoodId]

        return 'phase_%s/dna/%s_%s.dna' % (phase, hood, zoneId)

    def loadDNAFileAI(self, dnastore, filename):
        f = Filename('../resources/' + str(filename))
        f.setExtension('pdna')
        x = self.__loader.loadDNAFileAI(dnastore, f)
class ToontownUberRepository(ToontownInternalRepository):
    def __init__(self, baseChannel, serverId):
        ToontownInternalRepository.__init__(self, baseChannel, serverId, dcSuffix = 'UD')
        self.__loader = DNALoader.DNALoader()
        self.__dnaMap = {}
        
    def getDnaStore(self, zoneId):
        if zoneId in self.__dnaMap:
            return self.__dnaMap[zoneId]
            
        x = DNAStorage.DNAStorage()
        filename = self.genDNAFileName(zoneId)
        
        print 'Loading dna file', self.genDNAFileName(zoneId)
        self.loadDNAFileAI(x, filename)
        
        self.__dnaMap[zoneId] = x
        
        return x
        
    def handleConnected(self):
        rootObj = DistributedDirectoryAI(self)
        rootObj.generateWithRequiredAndId(self.getGameDoId(), 0, 0)
        
        self.apiMgr = ShardAPIManagerUD(self)
        self.apiMgr.generateWithRequiredAndId(100001, 0, 0)
        
        self.banMgr = BanManagerUD(self)
        self.banMgr.generateWithRequiredAndId(100002, 0, 0)

        self.createGlobals()
        
        self.apiWS = ShardAPIWebServer.start(self.apiMgr)

    def createGlobals(self):
        self.csm = simbase.air.generateGlobalObject(OTP_DO_ID_CLIENT_SERVICES_MANAGER,
                                                    'ClientServicesManager')

        self.chatAgent = simbase.air.generateGlobalObject(OTP_DO_ID_CHAT_MANAGER,
                                                          'ChatAgent')
        
        self.friendsManager = simbase.air.generateGlobalObject(OTP_DO_ID_TT_FRIENDS_MANAGER,
                                                               'TTFriendsManager')

        self.globalPartyMgr = simbase.air.generateGlobalObject(OTP_DO_ID_GLOBAL_PARTY_MANAGER, 'GlobalPartyManager')
        
        if config.GetBool('want-top-toons', True):
            if OTP_DO_ID_TOONTOWN_TOP_TOONS_MGR == 100003:
                self.topToonsMgr = DistributedTopToonsManagerUD(self)
                self.topToonsMgr.generateWithRequiredAndId(100003, self.getGameDoId(), 2)
                
                dg = PyDatagram()
                dg.addServerHeader(100003, self.ourChannel, STATESERVER_OBJECT_SET_AI)
                dg.addChannel(self.ourChannel)
                self.send(dg)
            
            else:
                self.topToonsMgr = self.generateGlobalObject(OTP_DO_ID_TOONTOWN_TOP_TOONS_MGR, 'DistributedTopToonsManager')
        
    def genDNAFileName(self, zoneId):
        zoneId = ZoneUtil.getCanonicalZoneId(zoneId)
        hoodId = ZoneUtil.getCanonicalHoodId(zoneId)
        hood = ToontownGlobals.dnaMap[hoodId]
        if hoodId == zoneId:
            zoneId = 'sz'
            phase = ToontownGlobals.phaseMap[hoodId]
        else:
            phase = ToontownGlobals.streetPhaseMap[hoodId]

        return 'phase_%s/dna/%s_%s.dna' % (phase, hood, zoneId)

    def loadDNAFileAI(self, dnastore, filename):
        f = Filename('../resources/' + str(filename))
        f.setExtension('pdna')            
        x = self.__loader.loadDNAFileAI(dnastore, f)