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
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
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)
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
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]]
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]]
def getOldCmds(): return configure.getJson('poker:oldcmd', {})
def getCmds(): return configure.getJson('poker:cmd', {})
def getIntegrate(): return configure.getJson('poker:global', {}).get('integrate', {})
def doGetConfigOnline2(self, key): conf = configure.getJson(key, {}, None) return conf
def getConnLogoutMsg(errorCode, defaultVal): ''' 关闭TCP连接时, 通知客户端的error消息内容 ''' pgdict = configure.getJson('poker:global') return pgdict.get('conn_logout_error_msg_' + str(errorCode), defaultVal)
def eventIdToString(eventId): eventIds = configure.getJson('poker:map.bieventid', {}) for key, value in eventIds.iteritems(): if eventId == value: return key return "UNKNOWN"