示例#1
0
def getGaoFangIp2(userId, clientId):
    ip, port = '', 0
    try:
        gaofangConfs = configure.getJson('poker:map.gaofangip.2', {})
        policy = gaofangConfs.get('policy')
        if policy == 'defence2':
            intClientId = sessiondata.getClientIdNum(userId, clientId)
            clientIds = gaofangConfs['clientIds']
            areaId = clientIds.get(intClientId)
            if not areaId:
                areaId = clientIds.get(str(intClientId))
                if not areaId:
                    areaId = clientIds.get('default')
                    if not areaId:
                        areaId = gaofangConfs['areas'].keys()[0]
                    ftlog.warn('ERROR, getGaoFangIp2 not found area id of ',
                               intClientId, clientId, 'use default !')
                clientIds[intClientId] = areaId
            entrys = gaofangConfs['areas'][areaId]
            ipPorts = random.choice(entrys)  # 切换不同的端口接入
            ipPort = ipPorts[userId % len(ipPorts)]  # 使用相对固定的IP地址接入
            ip, port = ipPort[0], ipPort[1]
    except:
        ftlog.error()
    ftlog.info('getGaoFangIp2->', ip, port, userId, clientId)
    return ip, port
示例#2
0
def getGaoFangIp2(userId, clientId):
    ip, port, wsport = '', 0, 0
    try:
        gaofangConfs = configure.getJson('poker:map.gaofangip.2', {})
        policy = gaofangConfs.get('policy')
        if policy == 'defence2':
            intClientId = sessiondata.getClientIdNum(userId, clientId)
            clientIds = gaofangConfs['clientIds']
            areaId = clientIds.get(intClientId)
            if not areaId:
                areaId = clientIds.get(str(intClientId))
                if not areaId:
                    areaId = clientIds.get('default')
                    if not areaId:
                        areaId = gaofangConfs['areas'].keys()[0]
                    ftlog.warn('ERROR, getGaoFangIp2 not found area id of ',
                               intClientId, clientId, 'use default !')
                clientIds[intClientId] = areaId
            entrys = gaofangConfs['areas'][areaId]
            ipPorts = entrys[userId % len(entrys)] # 切换不同的端口接入
            ipPort = ipPorts[userId % len(ipPorts)] # 使用相对固定的IP地址接入
            ip, port = ipPort[0], ipPort[1]
            if len(ipPort) > 2 :
                wsport = ipPort[2]
    except:
        ftlog.error()
    ftlog.info('getGaoFangIp2->', ip, port, wsport, userId, clientId)
    return ip, port, wsport
示例#3
0
def _adjustHallSessionInfo(redisfullkey, alldata):
    if not alldata:
        return

    if ftlog.is_debug():
        ftlog.debug('hallconf._adjustHallSessionInfo', 'redisfullkey=',
                    redisfullkey, 'alldata=', alldata)

    redisfullkey = redisfullkey.replace(':hall.info', ':table.tbbox')
    tbbox = configure.getJson(redisfullkey, {}, 0)
    tbboxrooms = tbbox.get('rooms', {})
    convert = getattr(alldata, 'convert', None)
    if convert:
        return

    for _, si in alldata['session_items'].items():
        rooms = si['rooms']
        convertRooms = []
        for x in xrange(len(rooms)):
            roomItemKey = rooms[x]
            roomItem = alldata['room_items'].get(roomItemKey)
            if roomItem:
                rid = roomItem.get('id')
                convertRooms.append(roomItem)
                roomtbbox = tbboxrooms.get(str(rid))
                if roomtbbox and roomtbbox.get('playCount', 0) > 1:
                    items = roomtbbox.get('reward', {}).get('items', {})
                    items = strutil.cloneData(items)
                    for item in items:
                        item['name'] = translateAssetKindIdToOld(
                            item['itemId'])
                    roomItem['tbbox'] = {
                        'pt': roomtbbox.get('playCount', 0),
                        'rewards': items
                    }
            else:
                ftlog.error(
                    'hallconf._adjustHallSessionInfo UnknownRoomItemKey roomItemKey=',
                    roomItemKey)

        si['rooms'] = convertRooms

    for tname, ss in alldata['templates'].items():
        convertSS = []
        alldata['templates'][tname] = convertSS
        for x in xrange(len(ss)):
            sessionItemKey = ss[x]
            sessionItem = alldata['session_items'].get(sessionItemKey)
            if sessionItem:
                convertSS.append(sessionItem)
            else:
                ftlog.error(
                    'hallconf._adjustHallSessionInfo UnknownSessionItemKey sessionItemKey=',
                    sessionItemKey)
示例#4
0
def getGaoFangIp(clientId, ip, port):
    try:
        _, cver, _ = strutil.parseClientId(clientId)
        gaofangConfs = configure.getJson('poker:map.gaofangip', None)
        if gaofangConfs:
            policy = gaofangConfs['policy']
            if policy == 'tuyou':
                ip = gaofangConfs[policy].get(ip, ip)

            elif policy == 'aligaofang':
                original = gaofangConfs['original']
                group = original[ip + ':' + str(port)]
                groupIps = gaofangConfs[policy][group]
                if groupIps:
                    ip = random.choice(groupIps)
            if cver >= 3.78:
                ip = gaofangConfs['namespace'][ip]
    except:
        ftlog.error()
    ftlog.info('getGaoFangIp->', ip, port, clientId)
    return ip, port
示例#5
0
def getGaoFangIp(clientId, ip, port):
    try:
        _, cver, _ = strutil.parseClientId(clientId)
        gaofangConfs = configure.getJson('poker:map.gaofangip', None)
        if gaofangConfs:
            policy = gaofangConfs['policy']
            if policy == 'tuyou':
                ip = gaofangConfs[policy].get(ip, ip)

            elif policy == 'aligaofang':
                original = gaofangConfs['original']
                group = original[ip + ':' + str(port)]
                groupIps = gaofangConfs[policy][group]
                if groupIps:
                    ip = random.choice(groupIps)
            if cver >= 3.78:
                ip = gaofangConfs['namespace'][ip]
    except:
        ftlog.error()
    ftlog.info('getGaoFangIp->', ip, port, clientId)
    return ip, port
示例#6
0
文件: hallconf.py 项目: zhaozw/hall37
def _adjustHallSessionInfo(redisfullkey, alldata):
    if not alldata:
        return
    redisfullkey = redisfullkey.replace(':hall.info', ':table.tbbox')
    tbbox = configure.getJson(redisfullkey, {}, 0)
    tbboxrooms = tbbox.get('rooms', {})
    for _, si in alldata['session_items'].items():
        rooms = si['rooms']
        for x in xrange(len(rooms)):
            rooms[x] = alldata['room_items'][rooms[x]]
            rid = rooms[x]['id']
            roomtbbox = tbboxrooms.get(str(rid))
            if roomtbbox and roomtbbox.get('playCount', 0) > 1:
                items = roomtbbox.get('reward', {}).get('items', {})
                items = strutil.cloneData(items)
                for item in items:
                    item['name'] = translateAssetKindIdToOld(item['itemId'])
                rooms[x]['tbbox'] = {'pt': roomtbbox.get('playCount', 0),
                                     'rewards': items}
    for _, ss in alldata['templates'].items():
        for x in xrange(len(ss)):
            ss[x] = alldata['session_items'][ss[x]]
示例#7
0
文件: hallconf.py 项目: zhaozw/hall37
def _adjustHallSessionInfo(redisfullkey, alldata):
    if not alldata:
        return
    redisfullkey = redisfullkey.replace(':hall.info', ':table.tbbox')
    tbbox = configure.getJson(redisfullkey, {}, 0)
    tbboxrooms = tbbox.get('rooms', {})
    for _, si in alldata['session_items'].items():
        rooms = si['rooms']
        for x in xrange(len(rooms)):
            rooms[x] = alldata['room_items'][rooms[x]]
            rid = rooms[x]['id']
            roomtbbox = tbboxrooms.get(str(rid))
            if roomtbbox and roomtbbox.get('playCount', 0) > 1:
                items = roomtbbox.get('reward', {}).get('items', {})
                items = strutil.cloneData(items)
                for item in items:
                    item['name'] = translateAssetKindIdToOld(item['itemId'])
                rooms[x]['tbbox'] = {
                    'pt': roomtbbox.get('playCount', 0),
                    'rewards': items
                }
    for _, ss in alldata['templates'].items():
        for x in xrange(len(ss)):
            ss[x] = alldata['session_items'][ss[x]]
示例#8
0
def getOldCmds():
    return configure.getJson('poker:oldcmd', {})
示例#9
0
def getCmds():
    return configure.getJson('poker:cmd', {})
示例#10
0
def getIntegrate():
    return configure.getJson('poker:global', {}).get('integrate', {})
示例#11
0
文件: httpgame.py 项目: zhaozw/hall37
 def doGetConfigOnline2(self, key):
     conf = configure.getJson(key, {}, None)
     return conf
示例#12
0
def getConnLogoutMsg(errorCode, defaultVal):
    '''
    关闭TCP连接时, 通知客户端的error消息内容
    '''
    pgdict = configure.getJson('poker:global')
    return pgdict.get('conn_logout_error_msg_' + str(errorCode), defaultVal)
示例#13
0
def getOldCmds():
    return configure.getJson('poker:oldcmd', {})
示例#14
0
def getCmds():
    return configure.getJson('poker:cmd', {})
示例#15
0
def getIntegrate():
    return configure.getJson('poker:global', {}).get('integrate', {})
示例#16
0
def getConnLogoutMsg(errorCode, defaultVal):
    '''
    关闭TCP连接时, 通知客户端的error消息内容
    '''
    pgdict = configure.getJson('poker:global')
    return pgdict.get('conn_logout_error_msg_' + str(errorCode), defaultVal)
示例#17
0
 def doGetConfigOnline2(self, key):
     conf = configure.getJson(key, {}, None)
     return conf
def eventIdToString(eventId):
    eventIds = configure.getJson('poker:map.bieventid', {})
    for key, value in eventIds.iteritems():
        if eventId == value:
            return key
    return "UNKNOWN"