def sendLed(gameId, msgstr, ismgr): if ftlog.is_debug(): ftlog.debug('hallled.sendLed gameId=', gameId, 'msgstr=', msgstr, 'ismgr=', ismgr) if not ismgr: ledRandomMod = hallconf.getHallPublic().get('led.manager.timeout', 3) randint = random.randint(0, ledRandomMod - 1) if randint % ledRandomMod != 0: if ftlog.is_debug(): ftlog.debug('hallled.sendLed Failed gameId=', gameId, 'msgstr=', msgstr, 'ismgr=', ismgr, 'noRandom') return try: msgDict = decodeMsg(gameId, msgstr) msg = [0, gameId, msgDict] leds = _LEDS kmsg = 'm:' + str(gameId) ktime = 't:' + str(gameId) if ismgr: leds[kmsg] = [msg] leds[ktime] = datetime.now() else: if not kmsg in leds: leds[kmsg] = [] leds[ktime] = None timeout = leds[ktime] if timeout != None: timeouts = hallconf.getHallPublic().get( 'led.manager.timeout', 30) secondes = (datetime.now() - timeout).seconds if secondes < timeouts: if ftlog.is_debug(): ftlog.debug('hallled.sendLed Failed gameId=', gameId, 'msgstr=', msgstr, 'ismgr=', ismgr, 'timeouts=', timeouts, 'secondes=', secondes) return msgq = leds[kmsg] msgq.append(msg) ledlength = 3 leds[ktime] = datetime.now() leds[kmsg] = msgq[-ledlength:] if ftlog.is_debug(): ftlog.debug('hallled.sendLed gameId=', gameId, 'msgstr=', msgstr, 'ismgr=', ismgr, 'msg=', msg, 'leds=', leds, 'LEDS=', _LEDS) return msg except: ftlog.error('hallled.sendLed gameId=', gameId, 'msgstr=', msgstr, 'ismgr=', ismgr) return None
def _initialize(): global _instance newShortUrlSwitch = hallconf.getHallPublic().get('newShortUrlSwitch', 1) if not _instance and not newShortUrlSwitch: _instance = ShortUrlx3me('bqkVoGCAYx', 'EuOLQYtTwyrrkdSKEZWlgqOHRgMPtoZK') _instance.initialize(gdata.serverType()) ftlog.info('hall_short_url._initialize')
def longUrlToShort(longUrl): if hallconf.getHallPublic().get('newShortUrlSwitch', 1): return getShortUrlNew(longUrl) global _instance if not _instance: ftlog.warn('hall_short_url.longUrlToShort not init') return longUrl return _instance.translate(longUrl)
def getLedMsgList(gameId): leds = _LEDS kmsg = 'm:' + str(gameId) ktime = 't:' + str(gameId) msgList = leds.get(kmsg, []) if msgList: timeouts = hallconf.getHallPublic().get('led.manager.timeout', 30) sendTime = leds.get(ktime) if (sendTime and (datetime.now() - sendTime).seconds >= timeouts): return [] return msgList
def getLedMsgList(gameId): leds = _LEDS kmsg = 'm:' + str(gameId) ktime = 't:' + str(gameId) msgList = leds.get(kmsg, []) if msgList: timeouts = hallconf.getHallPublic().get( 'led.manager.timeout', 40) # 从测试数据看客户端heartBeat间隔时间有10秒误差,也就是在30到40秒之间 sendTime = leds.get(ktime) ftlog.debug('halllend.sendLed gameId=', gameId, 'leds=', leds, 'sendTime=', sendTime, 'nowTime=', datetime.now()) if (sendTime and (datetime.now() - sendTime).seconds >= timeouts): return [] return msgList
def processOnLineAttrChangedEvent(evt): userId = evt.userId # gameId = evt.gameId attName = evt.attName attFinalValue = evt.attFinalValue # attDetalValue = evt.attDetalValue if attName == 'chip': richchip = hallconf.getHallPublic().get('online_rich_limit', 100000) if richchip > 0: if attFinalValue > richchip: onlinedata.setGameOnline(userId, HALL_GAMEID, 'rich_online_users') else: onlinedata.setGameOffline(userId, HALL_GAMEID, 'rich_online_users')
def getLedMsgList(gameId): leds = _LEDS kmsg = 'm:' + str(gameId) ktime = 't:' + str(gameId) msgList = leds.get(kmsg, []) if msgList: timeouts = hallconf.getHallPublic().get('led.manager.timeout', 40) # 从测试数据看客户端heartBeat间隔时间有10秒误差,也就是在30到40秒之间 sendTime = leds.get(ktime) ftlog.debug('halllend.sendLed gameId=', gameId, 'leds=', leds, 'sendTime=', sendTime, 'nowTime=', datetime.now()) if (sendTime and (datetime.now() - sendTime).seconds >= timeouts): return [] return msgList
def getLedMsgList(gameId): """根据游戏gameId获取Led信息""" leds = _LEDS kmsg = "m:" + str(gameId) ktime = "t:" + str(gameId) msgList = leds.get(kmsg, []) if msgList: timeouts = hallconf.getHallPublic().get( "led.manager.timeout", 30) # 从测试数据看客户端heartBeat间隔时间有10秒误差,也就是在30到40秒之间 sendTime = leds.get(ktime) isTimeout = sendTime and (datetime.now() - sendTime).seconds >= timeouts if ftlog.is_debug(): ftlog.debug("led.getLedMsgList gameId=", gameId, "leds=", leds, "sendTime=", sendTime, "nowTime=", datetime.now(), "isTimeout=", isTimeout) if isTimeout: return [] return msgList
def processOnLineTcpChangedEvent(evt): userId = evt.userId isOnline = evt.isOnline # 设置在线状态和在线用户集合列表, 离线时,所有通过setGameOnline设置的该用户数据均已经被删除 onlinedata.setOnlineState(userId, isOnline) if not isOnline: ctfull = timestamp.formatTimeMs() gamedata.setGameAttr(userId, HALL_GAMEID, 'offlineTime', ctfull) return # 计算其他的数据在线分组 # 分金币数量级别列表 — 德州等LED引导 richchip = hallconf.getHallPublic().get('online_rich_limit', 100000) if richchip > 0: chip = userchip.getUserChipAll(userId) if chip > richchip: onlinedata.setGameOnline(userId, HALL_GAMEID, 'rich_online_users') # 分版本 # 分等级(可能是大师分,或经验值) # 新老用户(是否第一天注册) # 有没有玩过某些游戏 # 是否有道具 # 是否充值 # 是否满足比赛报名条件 pass
def sendLed(gameId, msgstr, ismgr=0, scope="hall", clientIds=None, isStopServer=False): """ 发送LED @param gameId: 游戏gameId,gameId部分起到了过滤/范围的作用 @param msgstr: LED消息内容 @param ismgr: 是否是GDSS发的,默认非GDSS发送的 @param scope: string类型,LED显示级别/范围,详见http://192.168.10.93:8090/pages/viewpage.action?pageId=1281059 scope摘要 - "6": 只在地主插件里面播放 - "hall": 在大厅界面播放 - "hall6": 在大厅和地主插件里面播放 - "global": 在大厅任何界面都播放 @param clientIds: 不发送的clientId集合,默认全发送 @param isStopServer: 是否是停服led """ assert isinstance(msgstr, basestring) clientIds = clientIds or [] closeLedGameIds = hallconf.getPublicConf("closeLedGameIds", []) if not isStopServer and closeLedGameIds and gameId in closeLedGameIds: if ftlog.is_debug(): ftlog.debug("led.sendLed closed", "gameId=", gameId, "msgstr=", msgstr, "scope=", scope, "ismgr=", ismgr, "isStopServer=", isStopServer) return None if ftlog.is_debug(): ftlog.debug("led.sendLed gameId=", gameId, "msgstr=", msgstr, "scope=", scope, "ismgr=", ismgr, "isStopServer=", isStopServer) try: msgDict = decodeMsg(gameId, msgstr) # 每条LED所包含的数据内容 msg = [0, gameId, msgDict, scope, clientIds, isStopServer] leds = _LEDS kmsg = "m:" + str(gameId) ktime = "t:" + str(gameId) if ismgr: leds[kmsg] = [msg] leds[ktime] = datetime.now() else: if not kmsg in leds: leds[kmsg] = [] leds[ktime] = None timeout = leds[ktime] if timeout != None: timeouts = hallconf.getHallPublic().get( "led.manager.timeout", 30) secondes = (datetime.now() - timeout).seconds if secondes < timeouts: if ftlog.is_debug(): ftlog.warn("led.sendLed Failed gameId=", gameId, "msgstr=", msgstr, "ismgr=", ismgr, "scope=", scope, "timeouts=", timeouts, "secondes=", secondes) return msgq = leds[kmsg] msgq.append(msg) ledlength = 3 leds[ktime] = datetime.now() leds[kmsg] = msgq[-ledlength:] if ftlog.is_debug(): ftlog.debug("led.sendLed gameId=", gameId, "msgstr=", msgstr, "ismgr=", ismgr, "msg=", msg, "leds=", _LEDS) return msg except: ftlog.error("led.sendLed gameId=", gameId, "msgstr=", msgstr, "scope=", scope, "ismgr=", ismgr, "leds=", _LEDS) return None
def _reloadConf(): global newuser_startchip conf = hallconf.getHallPublic() newuser_startchip = conf['newuser_startchip']
def sendLed(gameId, msgstr, ismgr=0, scope='hall', clientIds=[], isStopServer=False, **kwargs): ''' 发送LED @param gameId: 游戏gameId,gameId部分起到了过滤/范围的作用 @param msgstr: LED消息内容 @param ismgr: 是否是GDSS发的,默认非GDSS发送的 @param scope: string类型,LED显示级别/范围,详见http://192.168.10.93:8090/pages/viewpage.action?pageId=1281059 scope摘要 - '6': 只在地主插件里面播放 - 'hall': 在大厅界面播放 - 'hall6': 在大厅和地主插件里面播放 - 'global': 在大厅任何界面都播放 @param clientIds: 发送的clientId集合,默认全发送 @param isStopServer: 是否是停服led ''' if not kwargs.get('active', 0): return assert isinstance(msgstr, basestring) closeLedGameIds = hallconf.getPublicConf('closeLedGameIds', []) if not isStopServer and closeLedGameIds and gameId in closeLedGameIds: if ftlog.is_debug(): ftlog.debug('hallled.sendLed closed', 'gameId=', gameId, 'msgstr=', msgstr, 'scope=', scope, 'ismgr=', ismgr, 'isStopServer=', isStopServer) return None if ftlog.is_debug(): ftlog.debug('hallled.sendLed gameId=', gameId, 'msgstr=', msgstr, 'scope=', scope, 'ismgr=', ismgr, 'isStopServer=', isStopServer) try: msgDict = decodeMsg(gameId, msgstr) msg = [0, gameId, msgDict, scope, clientIds, isStopServer] leds = _LEDS kmsg = 'm:' + str(gameId) ktime = 't:' + str(gameId) if ismgr: leds[kmsg] = [msg] leds[ktime] = datetime.now() else: if not kmsg in leds: leds[kmsg] = [] leds[ktime] = None timeout = leds[ktime] if timeout != None: timeouts = hallconf.getHallPublic().get( 'led.manager.timeout', 40) secondes = (datetime.now() - timeout).seconds if secondes < timeouts: if ftlog.is_debug(): ftlog.warn('hallled.sendLed Failed gameId=', gameId, 'msgstr=', msgstr, 'ismgr=', ismgr, 'scope=', scope, 'timeouts=', timeouts, 'secondes=', secondes) return msgq = leds[kmsg] msgq.append(msg) ledlength = 3 leds[ktime] = datetime.now() leds[kmsg] = msgq[-ledlength:] if ftlog.is_debug(): ftlog.debug('hallled.sendLed gameId=', gameId, 'msgstr=', msgstr, 'ismgr=', ismgr, 'msg=', msg, 'leds=', _LEDS) return msg except: ftlog.error('hallled.sendLed gameId=', gameId, 'msgstr=', msgstr, 'scope=', scope, 'ismgr=', ismgr, 'leds=', _LEDS) return None
def sendLed(gameId, msgstr, ismgr=0, scope='hall', clientIds=[]): ''' 发送LED @param gameId: 游戏gameId,gameId部分起到了过滤/范围的作用 @param msgstr: LED消息内容 @param ismgr: 是否是GDSS发的,默认非GDSS发送的 @param scope: string类型,LED显示级别/范围,详见http://192.168.10.93:8090/pages/viewpage.action?pageId=1281059 scope摘要 - '6': 只在地主插件里面播放 - 'hall': 在大厅界面播放 - 'hall6': 在大厅和地主插件里面播放 - 'global': 在大厅任何界面都播放 @param clientIds: 发送的clientId集合,默认全发送 ''' assert isinstance(msgstr, basestring) if ftlog.is_debug(): ftlog.debug('hallled.sendLed gameId=', gameId, 'msgstr=', msgstr, 'scope=', scope, 'ismgr=', ismgr) try: msgDict = decodeMsg(gameId, msgstr) msg = [0, gameId, msgDict, scope, clientIds] leds = _LEDS kmsg = 'm:' + str(gameId) ktime = 't:' + str(gameId) if ismgr: leds[kmsg] = [msg] leds[ktime] = datetime.now() else: if not kmsg in leds: leds[kmsg] = [] leds[ktime] = None timeout = leds[ktime] if timeout != None: timeouts = hallconf.getHallPublic().get('led.manager.timeout', 40) secondes = (datetime.now() - timeout).seconds if secondes < timeouts: if ftlog.is_debug(): ftlog.warn('hallled.sendLed Failed gameId=', gameId, 'msgstr=', msgstr, 'ismgr=', ismgr, 'scope=', scope, 'timeouts=', timeouts, 'secondes=', secondes) return msgq = leds[kmsg] msgq.append(msg) ledlength = 3 leds[ktime] = datetime.now() leds[kmsg] = msgq[-ledlength:] if ftlog.is_debug(): ftlog.debug('hallled.sendLed gameId=', gameId, 'msgstr=', msgstr, 'ismgr=', ismgr, 'msg=', msg, 'leds=', _LEDS) return msg except: ftlog.error('hallled.sendLed gameId=', gameId, 'msgstr=', msgstr, 'scope=', scope, 'ismgr=', ismgr, 'leds=', _LEDS) return None