Beispiel #1
0
def _initByData(svrid, sc, rc, glc, conf):
    global global_config
    global_config.update(json.loads(glc))

    # init log system...
    log_file = "%s.log" % svrid
    log_path = global_config["log_path"]
    ftlog.trace_stdout("FreeTime service(%s) up, log to %s/%s..." % (svrid, log_path, log_file))
    log_level = int(global_config.get("log_level", 0))
    # skip twisted noisy in no-debug level...
    if log_level > 0:
        Factory.noisy = False
    if ide_debug():
        ftlog.initLog(log_file, log_path, log_level)
        # ftlog.initLog(log_file, 'stdout', log_level)
    else:
        ftlog.initLog(log_file, log_path, log_level)

    # init maps...
    ftlog.info("init from redis:", conf[0], conf[1], conf[2])
    _initServerMap(json.loads(sc))
    dbs = json.loads(rc)
    global_config['freetime:db'] = dbs
    if "redis" in dbs:
        _initRedisPoolMap(svrid, conf, dbs["redis"])
    if "mysql" in dbs:
        _initMysqlPoolMap(svrid, conf, dbs["mysql"])
Beispiel #2
0
def _initByData(svrid, sc, rc, glc, conf):
    global global_config
    global_config.update(json.loads(glc))

    # init log system...
    log_file = "%s.log" % svrid
    log_path = global_config["log_path"]
    ftlog.trace_stdout("FreeTime service(%s) up, log to %s/%s..." %
                       (svrid, log_path, log_file))
    log_level = int(global_config.get("log_level", 0))
    # skip twisted noisy in no-debug level...
    if log_level > 0:
        Factory.noisy = False
    if ide_debug():
        ftlog.initLog(log_file, log_path, log_level)
        # ftlog.initLog(log_file, 'stdout', log_level)
    else:
        ftlog.initLog(log_file, log_path, log_level)

    # init maps...
    ftlog.info("init from redis:", conf[0], conf[1], conf[2])
    _initServerMap(json.loads(sc))
    dbs = json.loads(rc)
    global_config['freetime:db'] = dbs
    if "redis" in dbs:
        _initRedisPoolMap(svrid, conf, dbs["redis"])
    if "mysql" in dbs:
        _initMysqlPoolMap(svrid, conf, dbs["mysql"])
Beispiel #3
0

def loadRoomInfo(gameId, roomId):
    return None


def saveRoomInfo(gameId, roomInfo):
    pass


def removeRoomInfo(gameId, roomId):
    pass


if __name__ == '__main__':
    ftlog.initLog('groupmatch.log', './logs/')
    matchId = 6057
    masterRoomId = 60571
    areaRoomIds = [60571]
    roominfo.saveRoomInfo = saveRoomInfo
    roominfo.removeRoomInfo = removeRoomInfo
    roominfo.loadRoomInfo = loadRoomInfo
    matchConf = MatchConfig.parse(6, 60571, 6057, '满3人开赛',
                                  match_conf['matchConf'])
    signerInfoLoader = SignerInfoLoaderTest()
    areas = []
    master = buildMatchMaster(masterRoomId, matchId, matchConf)
    for areaRoomId in areaRoomIds:
        area = buildMatchArea(areaRoomId, matchId, matchConf, master)
        areas.append(area)
        master.addArea(area)
Beispiel #4
0
    def _isAllReady(self):
        if not self._master.instCtrl:
            return False
        for area in self._areaMap.values():
            if not area.curInst:
                return False
        return True

    def _signinToMatch(self, area, userIds):
        for userId in userIds:
            area.curInst.signin(userId)


if __name__ == '__main__':
    ftlog.initLog('groupmatch.log', './logs/')
    # ftlog.LOG_LEVEL_DEBUG = 0
    matchId = 6057
    masterRoomId = 60571
    areaRoomIds = [60571, 60572, 60573]
    matchConf = MatchConfig.parse(6, 60571, 6057, '满3人开赛', match_conf['matchConf'])
    areas = []
    userInfoLoader = UserInfoLoaderTest()
    master = buildMatchMaster(masterRoomId, matchId, matchConf)
    for areaRoomId in areaRoomIds:
        area = buildMatchArea(areaRoomId, matchId, matchConf, master)
        areas.append(area)
        area.userInfoLoader = userInfoLoader
        master.addAreaStub(MatchAreaStubLocal(master, area))

    master.start()