Ejemplo n.º 1
0
 def _check_param_appId(self, key, params):
     appId = runhttp.getParamInt(key, 0)
     ftlog.debug('BaseHttpMsgChecker._check_param_appId key=', key,
                 'params=', params, 'appId=', appId, 'gameIds=',
                 gdata.gameIds())
     if not appId in gdata.gameIds():
         return 'param appId error', None
     return None, appId
Ejemplo n.º 2
0
 def _check_param_appId(self, key, params):
     appId = runhttp.getParamInt(key, 0)
     ftlog.debug('BaseHttpMsgChecker._check_param_appId key=', key,
                 'params=', params,
                 'appId=', appId,
                 'gameIds=', gdata.gameIds())
     if not appId in gdata.gameIds():
         return 'param appId error', None
     return None, appId
Ejemplo n.º 3
0
 def _check_param_appId(self, key, params):
     appId = runhttp.getParamInt(key, 0)
     if appId == 0:
         appId = runhttp.getParamInt('gameId', 0)
     if not appId in gdata.gameIds():
         return 'param appId error', None
     return None, appId
Ejemplo n.º 4
0
 def _initCandidateRoomIds(cls):
     global _CANDIDATE_ROOM_IDS
     croomids = {}
     for gameId in gdata.gameIds():
         roomids = cls._initCandidateRoomIdsByGameId(gameId)
         croomids[gameId] = roomids
     _CANDIDATE_ROOM_IDS = croomids
Ejemplo n.º 5
0
 def _check_param_appId(self, key, params):
     appId = runhttp.getParamInt(key, 0)
     if appId == 0:
         appId = runhttp.getParamInt('gameId', 0)
     if not appId in gdata.gameIds():
         return 'param appId error', None
     return None, appId
Ejemplo n.º 6
0
 def _collectInterestEventMap(self, taskKinds):
     interestEventMap = {}
     for taskKind in taskKinds:
         for eventType, gameIds in taskKind.inspector.interestEventMap.iteritems(
         ):
             gameIds = gameIds or gdata.gameIds()
             existsGameIds = interestEventMap.get(eventType)
             if not existsGameIds:
                 existsGameIds = set()
                 interestEventMap[eventType] = existsGameIds
             existsGameIds.update(gameIds)
     return interestEventMap
Ejemplo n.º 7
0
    def _collect_event_map(cls, task_kinds):
        event_map = {}
        for task_kind in task_kinds:
            for event_type, gids in task_kind.inspector.interestEventMap.iteritems(
            ):
                gids = gids or gdata.gameIds()
                exists_gids = event_map.get(event_type)
                if not exists_gids:
                    exists_gids = set()
                    event_map[event_type] = exists_gids

                exists_gids.update(gids)
        return event_map
Ejemplo n.º 8
0
    def doHelloTuyou(self):
        gameId = runhttp.getParamInt('gameId')
        clientId = runhttp.getParamStr('clientId', '')
        ftlog.debug('Hello->gameId=', gameId, 'clientId=', clientId)

        mo = MsgPack()
        mo.setCmd('hello')

        if gameId not in gdata.gameIds():
            mo.setError(1, 'gameId error !')
            ftlog.error('doHelloTuyou gameId error', runhttp.getDict())
            return mo

        try:
            clientIdInt = pokerconf.clientIdToNumber(clientId)
        except:
            clientIdInt = 0
            ftlog.error()

        if clientIdInt <= 0:
            mo.setError(2, 'clientId error !')
            ftlog.error('doHelloTuyou clientId error', runhttp.getDict())
            return mo

        nicaiCode = runhttp.getParamStr('nicaiCode', '')
        if not nicaiCode:
            mo.setError(3, 'nicai error !')
            ftlog.error('doHelloTuyou nicai error', runhttp.getDict())
            return mo
        # 1. 生存你猜CODE
        HelloTuyou.getNiCaiCode(mo, nicaiCode)

        # 2. 取得更新信息
        updateVersion = runhttp.getParamInt('updateVersion')
        alphaVersion = runhttp.getParamInt('alphaVersion', 0)
        HelloTuyou.getUpdataInfo(mo, gameId, clientId, updateVersion, alphaVersion)

        # 3. 静态配置文件的MD5和URL
        staticConf = hallconf.getUpgradeStaticConf()
        mo.updateResult(staticConf)

        # 4. 返回三方SDK的控制开关
        HelloTuyou.getThirdSwitches(mo, clientId)

        # 设置其他返回值
        mo.setResult('gameId', gameId)
        mo.setResult('clientId', clientId)

        return mo
Ejemplo n.º 9
0
def updateOnLineInfos(event):
    if event.count % 10 != 0:
        return

    allcount = 0
    ucounts = {}
    for gameId in gdata.gameIds():
        count, _, _ = bireport.getRoomOnLineUserCount(gameId)
        allcount += count
        ucounts[gameId] = count
    ucounts[HALL_GAMEID] = allcount

    _ONLINES.clear()
    _ONLINES.update(ucounts)
    ftlog.debug('updateOnLineInfos->', _ONLINES)
Ejemplo n.º 10
0
def updateOnLineInfos(event):
    if event.count % 10 != 0 :
        return

    allcount = 0
    ucounts = {}
    for gameId in gdata.gameIds():
        count, _, _ = bireport.getRoomOnLineUserCount(gameId)
        allcount += count
        ucounts[gameId] = count
    ucounts[HALL_GAMEID] = allcount

    _ONLINES.clear()
    _ONLINES.update(ucounts)
    ftlog.debug('updateOnLineInfos->', _ONLINES)
Ejemplo n.º 11
0
 def _registerEvents(self):
     for taskKind in self._taskKindMap.values():
         for inspector in taskKind.inspectors:
             for eventType, gameIds in inspector.interestEventMap.iteritems():
                 gameIds = gameIds or gdata.gameIds()
                 for gameId in gameIds:
                     game = gdata.games().get(gameId)
                     if game:
                         game.getEventBus().subscribe(eventType, self._handleEvent)
                         self._addInterestEventType(eventType, gameId)
                         if ftlog.is_debug():
                             ftlog.debug('TYTaskSystemImpl._registerEvents eventType=', eventType,
                                         'gameId=', gameId,
                                         'taskUnitId=', taskKind.taskUnit.taskUnitId)
                     else:
                         ftlog.warn('TYTaskSystemImpl._registerEvents gameId=', gameId,
                                    'err=', 'Not find game')
Ejemplo n.º 12
0
def getGameInfo(userId, clientId):
    '''
    取得当前用户的游戏账户信息dict
    '''
    ftlog.debug('hall.getGameInfo', userId, clientId)
    # 大厅游戏, 获取所有游戏的大师分
    gameids = hallconf.getDaShiFenFilter(clientId)
    allGameIds = gdata.gameIds()
    dashifen = {}
    i = 0
    for gid in gameids :
        if gid in allGameIds :
            infos = TYGame(gid).getDaShiFen(userId, clientId)
            if infos :
                infos['index'] = i
                dashifen[gid] = infos
                i = i + 1
    return {'dashifen' : dashifen}
Ejemplo n.º 13
0
def getGameInfo(userId, clientId):
    '''
    取得当前用户的游戏账户信息dict
    '''
    ftlog.debug('hall.getGameInfo', userId, clientId)
    # 大厅游戏, 获取所有游戏的大师分
    gameids = hallconf.getDaShiFenFilter(clientId)
    allGameIds = gdata.gameIds()
    dashifen = {}
    i = 0
    for gid in gameids:
        if gid in allGameIds:
            infos = TYGame(gid).getDaShiFen(userId, clientId)
            if infos:
                infos['index'] = i
                dashifen[gid] = infos
                i = i + 1
    return {'dashifen': dashifen}
Ejemplo n.º 14
0
    def doGameUpdateInfo(self):
        gameId = runhttp.getParamInt('gameId')
        clientId = runhttp.getParamStr('clientId', '')
        version = runhttp.getParamStr('version', '')
        updateVersion = runhttp.getParamInt('updateVersion', -1)

        ftlog.debug('http gameupdateinfo IN->gameId=', gameId, 'clientId=',
                    clientId, 'version=', version, 'updateVersion=',
                    updateVersion)

        mo = MsgPack()
        mo.setCmd('gameupdateinfo')

        if gameId not in gdata.gameIds():
            mo.setError(1, 'gameId error !')
            return mo

        clientIdInt = pokerconf.clientIdToNumber(clientId)
        if clientIdInt <= 0:
            mo.setError(2, 'clientId error !')
            return mo

        if not version:
            mo.setError(3, 'version error !')
            return mo

        if updateVersion < 0:
            mo.setError(4, 'updateVersion error !')
            return mo

        updates = hall_game_update.getUpdateInfo2(gameId, version,
                                                  updateVersion)

        ftlog.debug('http gameupdateinfo OUT->updates=', updates)

        mo.setResult('gameId', gameId)
        mo.setResult('clientId', clientId)
        mo.setResult('version', version)
        mo.setResult('updateVersion', updateVersion)
        mo.setResult('updates', updates)

        return mo
Ejemplo n.º 15
0
    def doHelloTuyou(self):
        gameId = runhttp.getParamInt('gameId')
        clientId = runhttp.getParamStr('clientId', '')
        ftlog.debug('Hello->gameId=', gameId, 'clientId=', clientId)

        mo = MsgPack()
        mo.setCmd('hello')

        if gameId not in gdata.gameIds():
            mo.setError(1, 'gameId error !')
            return mo

        clientIdInt = pokerconf.clientIdToNumber(clientId)
        if clientIdInt <= 0:
            mo.setError(2, 'clientId error !')
            return mo

        nicaiCode = runhttp.getParamStr('nicaiCode', '')
        if not nicaiCode:
            mo.setError(3, 'nicai error !')
            return mo
        # 1. 生存你猜CODE
        HelloTuyou.getNiCaiCode(mo, nicaiCode)

        # 2. 取得更新信息
        updateVersion = runhttp.getParamInt('updateVersion')
        alphaVersion = runhttp.getParamInt('alphaVersion', 0)
        HelloTuyou.getUpdataInfo(mo, gameId, clientId, updateVersion, alphaVersion)

        # 3. 静态配置文件的MD5和URL
        staticConf = hallconf.getUpgradeStaticConf()
        mo.updateResult(staticConf)

        # 4. 返回三方SDK的控制开关
        HelloTuyou.getThirdSwitches(mo, clientId)

        # 设置其他返回值
        mo.setResult('gameId', gameId)
        mo.setResult('clientId', clientId)

        return mo
Ejemplo n.º 16
0
 def _registerEvents(self):
     for taskKind in self._taskKindMap.values():
         for inspector in taskKind.inspectors:
             for eventType, gameIds in inspector.interestEventMap.iteritems(
             ):
                 gameIds = gameIds or gdata.gameIds()
                 for gameId in gameIds:
                     game = gdata.games().get(gameId)
                     if game:
                         game.getEventBus().subscribe(
                             eventType, self._handleEvent)
                         self._addInterestEventType(eventType, gameId)
                         if ftlog.is_debug():
                             ftlog.debug(
                                 'TYTaskSystemImpl._registerEvents eventType=',
                                 eventType, 'gameId=', gameId,
                                 'taskUnitId=',
                                 taskKind.taskUnit.taskUnitId)
                     else:
                         ftlog.warn(
                             'TYTaskSystemImpl._registerEvents gameId=',
                             gameId, 'err=', 'Not find game')