Beispiel #1
0
class GameTcpHandler(BaseMsgPackChecker):
    def __init__(self):
        self.helper = UtilHelper()

    @markCmdActionMethod(cmd='game', action="data", clientIdVer=0)
    def doGameData(self, userId, gameId, clientId):
        self.helper.sendUserInfoResponse(userId, gameId, clientId, '', 0, 1)

    @markCmdActionMethod(cmd='game', action="bindPhone", clientIdVer=0)
    def dosendChipToUser(self, userId, gameId, clientId):
        # 添加绑定
        nowBindPone = gamedata.getGameAttr(userId, gameId, 'bindReward1')
        if not nowBindPone or nowBindPone < 1:
            gamedata.setGameAttr(userId, gameId, 'bindReward1', 1)
        else:
            from poker.entity.biz.exceptions import TYBizException
            raise TYBizException(-1, '重复绑定')
        # 发金币
        ftlog.info('cmd game action bindPhone userId =', userId)
        from poker.entity.dao import userchip, daoconst
        userchip.incrChip(userId, gameId, 10000, daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, 'BIND_PHONE', 0, clientId)
        datachangenotify.sendDataChangeNotify(gameId, userId, 'chip')
        # 消息推送
        from poker.entity.biz.message import message
        msg = '恭喜您绑定手机成功,赠送您10000金币'
        message.send(gameId, message.MESSAGE_TYPE_PRIVATE, userId, msg)
        # 更新小红点
        datachangenotify.sendDataChangeNotify(gameId, userId, ['free', 'promotion_loc'])
        TGHall.getEventBus().publishEvent(UserBindPhoneEvent(userId, gameId))

    @markCmdActionMethod(cmd='game', action="enter", clientIdVer=0)
    def doGameEnter(self, userId, gameId, clientId):
        isdayfirst, iscreate = halluser.loginGame(userId, gameId, clientId)
        self.helper.sendUserInfoResponse(userId, gameId, clientId, '', 0, 1)
        self.helper.sendTodoTaskResponse(userId, gameId, clientId, isdayfirst)
        # BI日志统计
        bireport.userGameEnter(gameId, userId, clientId)
        bireport.reportGameEvent('BIND_GAME',
                                 userId, gameId, 0, 0, 0, 0, 0, 0, [], clientId, iscreate)
        evt = OnLineGameChangedEvent(userId, gameId, 1, clientId)
        TGHall.getEventBus().publishEvent(evt)

    @markCmdActionMethod(cmd='game', action="leave", clientIdVer=0)
    def doGameLeave(self, userId, gameId, clientId):
        evt = OnLineGameChangedEvent(userId, gameId, 0, clientId)
        TGHall.getEventBus().publishEvent(evt)

    @markCmdActionMethod(cmd='game', action='get_member_reward', clientIdVer=0)
    def doGameGetMemberReward(self, userId, gameId, clientId):
        userAssets = hallitem.itemSystem.loadUserAssets(userId)
        userBag = userAssets.getUserBag()
        memberCardItem = userBag.getItemByKindId(hallitem.ITEM_MEMBER_NEW_KIND_ID)
        timestamp = pktimestamp.getCurrentTimestamp()
        if memberCardItem and memberCardItem.canCheckin(timestamp):
            checkinAction = memberCardItem.itemKind.findActionByName('checkin')
            checkinAction.doAction(gameId, userAssets, memberCardItem, timestamp, {})
            datachangenotify.sendDataChangeNotify(gameId, userId, 'free')
            TodoTaskHelper.sendTodoTask(gameId, userId, TodoTaskGoldRain('恭喜您领取了今天的会员福利'))

    @markCmdActionMethod(cmd='game', action='get_exit_remind', clientIdVer=0)
    def doGameGetExitRemind(self, userId, gameId, clientId):
        hall_exit_remind.queryExitRemind(gameId, userId, clientId)

    @markCmdActionMethod(cmd='game', action='get_fangka_item', clientIdVer=0)
    def doGetFangKaItem(self, userId, gameId, clientId):
        hall_fangka.sendFangKaItemToClient(gameId, userId, clientId)

    @markCmdActionMethod(cmd='game', action='require_fangka_buy_info', clientIdVer=0)
    def doRequireFangBuyInfo(self, userId, gameId, clientId):
        hall_fangka_buy_info.queryFangKaBuyInfo(gameId, userId, clientId)

    @markCmdActionMethod(cmd='game', action='get_game_update_info', clientIdVer=0)
    def doGameGetUpdateInfo(self, userId, gameId, clientId, version, updateVersion):
        hall_game_update.getUpdateInfo(gameId, userId, clientId, version, updateVersion)

    @markCmdActionMethod(cmd='game', action='update_notify', clientIdVer=0)
    def doGameUpdateNotify(self, userId, gameId, clientId, module):
        '''
        通知前端更新消息
        '''
        from hall.entity.hallconf import HALL_GAMEID
        datachangenotify.sendDataChangeNotify(HALL_GAMEID, userId, module)

    @markCmdActionMethod(cmd='game', action='enter_friend_table', clientIdVer=0)
    def doEnterFriendTable(self, userId, gameId, clientId, ftId):
        '''
        通知前端更新消息
        '''
        hall_friend_table.enterFriendTable(userId, gameId, clientId, ftId)
Beispiel #2
0
class AccountTcpHandler(BaseMsgPackChecker):
    def __init__(self):
        self.helper = UtilHelper()

    def _check_param_newName(self, msg, key, params):
        newName = msg.getParam(key)
        if not newName or not isstring(newName):
            return 'Error param newName', None
        return None, newName

    def _check_param_msg(self, msg, key, params):
        msgstr = msg.getParam(key)
        if not msgstr or not isstring(msgstr):
            return 'Error param msg', None
        return None, msgstr

    def _check_param_ismgr(self, msg, key, params):
        ismgr = msg.getParam(key)
        if ismgr in (0, 1):
            return None, ismgr
        return 'Error param ismgr', None

    def _check_param_scope(self, msg, key, params):
        scope = msg.getParam(key)
        if not scope or not isstring(scope):
            return None, 'hall'
        return None, scope

    def _check_param_clientIds(self, msg, key, params):
        clientIds = msg.getParam(key)
        if not clientIds:
            return None, []
        return None, clientIds

    def _check_param_isTempVipUser(self, msg, key, params):
        isTempVipUser = msg.getParam(key, 0)
        if isTempVipUser in (0, 1):
            return None, isTempVipUser
        return 'Error param isTempVipUser', None

    def checkForceLogout(self, userId):
        '''
        检查是否运行登录
        '''
        if halluser.isForceLogout(userId):
            onlines.forceLogOut(userId, '')
            return 1
        return 0

    def recoverUserTableChips(self, userId, clientId):
        try:
            tableChips = userchip.getTableChipsAll(userId)
            ftlog.debug('recoverUserTableChips->', tableChips)
            datas = None
            if isinstance(tableChips, dict):
                datas = tableChips
            elif isinstance(tableChips, list):
                datas = {}
                for x in xrange(len(tableChips) / 2):
                    datas[tableChips[x * 2]] = tableChips[x * 2 + 1]
            delTablesIds = []
            for tableId, tchip in datas.items():
                tableId, tchip = strutil.parseInts(tableId, tchip)
                troomId = strutil.getTableRoomId(tableId)
                if not troomId or troomId <= 0:
                    delTablesIds.append(tableId)
                    continue
                gameId, _, _, _ = strutil.parseInstanceRoomId(troomId)
                if not gameId or gameId <= 0:
                    delTablesIds.append(tableId)
                    continue
                seatId = 0
                try:
                    seatId, _ = roommgr.doCheckUserLoc(userId, gameId, troomId, tableId, clientId)
                except:
                    delTablesIds.append(tableId)
                    ftlog.error()
                    continue

                if not seatId:
                    userchip.moveAllTableChipToChip(userId, gameId, 'TABLE_TCHIP_TO_CHIP', troomId, clientId, tableId)
                    delTablesIds.append(tableId)
                else:
                    # the user is on the table , do not clear
                    pass

            if delTablesIds:
                userchip.delTableChips(userId, delTablesIds)
        except:
            ftlog.error()

    @markCmdActionMethod(cmd='user', action='info', clientIdVer=0)
    def doUserInfo_0(self, userId):
        '''
        低版本不允许登录了
        '''
        onlines.forceLogOut(userId, '')

    @markCmdActionMethod(cmd='user', action='info', clientIdVer=3.0)
    def doUserInfo_3(self, userId, gameId, clientId, isFirstuserInfo):
        # 检查是否禁止登录
        if self.checkForceLogout(userId):
            return
        loc = ''
        if isFirstuserInfo:
            self._sendLocalStaticInfo(userId)
            loc = onlinedata.checkUserLoc(userId, clientId, 0)
            self.recoverUserTableChips(userId, clientId)
        # 发送udata和gdata响应消息
        self.helper.sendUserInfoResponse(userId, gameId, clientId, loc, 1, 1)

    def _sendLocalStaticInfo(self, userId):
        mo = hallversionmgr.makeStaticMessage()
        router.sendToUser(mo, userId)

    @markCmdActionMethod(cmd='user', action='info', clientIdVer=3.3)
    def doUserInfo_3_3(self, userId, gameId, clientId, isFirstuserInfo):
        # 检查是否禁止登录
        if self.checkForceLogout(userId):
            return
        loc = ''
        if isFirstuserInfo:
            loc = onlinedata.checkUserLoc(userId, clientId, 0)
            self.recoverUserTableChips(userId, clientId)
        # 发送udata响应消息
        self.helper.sendUserInfoResponse(userId, gameId, clientId, loc, 1, 0)

    @markCmdActionMethod(cmd='user', action='bind', clientIdVer=0)
    def doUserBind_0(self, userId, gameId, clientId, isFirstuserInfo):
        # 检查是否禁止登录
        if self.checkForceLogout(userId):
            return
        loc = ''
        if isFirstuserInfo:
            loc = onlinedata.checkUserLoc(userId, clientId, 0)
            self.recoverUserTableChips(userId, clientId)
        # # 更新基本信息
        #         halluser.updateUserBaseInfo(userId, clientId, runcmd.getMsgPack())
        # 登录游戏处理
        isdayfirst, _ = halluser.loginGame(userId, gameId, clientId)
        # 发送udata和gdata响应消息
        self.helper.sendUserInfoResponse(userId, gameId, clientId, loc, 1, 1)
        # 发送TodoTask消息
        self.helper.sendTodoTaskResponse(userId, gameId, clientId, isdayfirst)
        # 标记游戏时长开始
        gamedata.incrPlayTime(userId, 0, gameId)
        # BI日志统计
        bireport.userBindUser(gameId, userId, clientId)
        bireport.reportGameEvent('BIND_USER',
                                 userId, gameId, 0, 0, 0, 0, 0, 0, [], clientId)
        evt = OnLineGameChangedEvent(userId, gameId, 1, clientId)
        TGHall.getEventBus().publishEvent(evt)

    def _isReconnect(self, userId, gameId, clientId, loc):
        if loc:
            locList = loc.split(':')
            for subLoc in locList:
                if subLoc != '0.0.0.0':
                    return True
        return False

    @markCmdActionMethod(cmd='user', action='bind', clientIdVer=3.3)
    def doUserBind_3_3(self, userId, gameId, clientId, isFirstuserInfo):
        # 检查是否禁止登录
        if self.checkForceLogout(userId):
            return
        loc = ''
        isReconnect = False
        if isFirstuserInfo:
            loc = onlinedata.checkUserLoc(userId, clientId, 0)
            self.recoverUserTableChips(userId, clientId)
            isReconnect = self._isReconnect(userId, gameId, clientId, loc)
        # # 更新基本信息
        #         halluser.updateUserBaseInfo(userId, clientId, runcmd.getMsgPack())
        # 登录游戏处理
        isdayfirst, _ = halluser.loginGame(userId, gameId, clientId)
        # 发送udata响应消息
        self.helper.sendUserInfoResponse(userId, gameId, clientId, loc, 1, 0)
        # 发送gdata响应消息
        self.helper.sendUserInfoResponse(userId, gameId, clientId, loc, 0, 1)
        # 发送响应消息
        if not isReconnect:
            self.helper.sendTodoTaskResponse(userId, gameId, clientId, isdayfirst)
        # 标记游戏时长开始
        gamedata.incrPlayTime(userId, 0, gameId)
        # BI日志统计
        bireport.userBindUser(gameId, userId, clientId)
        bireport.reportGameEvent('BIND_USER',
                                 userId, gameId, 0, 0, 0, 0, 0, 0, [], clientId)

        evt = OnLineGameChangedEvent(userId, gameId, 1, clientId)
        TGHall.getEventBus().publishEvent(evt)

    @markCmdActionMethod(cmd='user', action='heart_beat', clientIdVer=0)
    def doUserHeartBeat(self, userId, gameId, clientId, isMust):
        hallled.doSendLedToUser(userId)
        clientIdVer = strutil.parseClientId(clientId)[1]
        if clientIdVer < 3.0:  # c++老版本斗地主才需要在heart_beat时下发m_signs 
            self._sendMatchSignsToUser(userId, gameId, clientId)
        self._sendOnLineInfoToUser(userId, gameId, clientId)

    @markCmdActionMethod(cmd='send_led', clientIdVer=0, lockParamName='send_led')
    def doSendLed(self, gameId, msg, ismgr, scope='hall', clientIds=[]):
        hallled.sendLed(gameId, msg, ismgr, scope, clientIds)

    @markCmdActionMethod(cmd='gain_nslogin_reward', clientIdVer=0)
    def doGainNSLoginReward(self, userId, gameId, clientId):
        checkinOk, rewardAssetList, _checkinDays = \
            halldailycheckin.dailyCheckin.gainCheckinReward(gameId, userId)
        rewardChipCount = 0
        if checkinOk:
            datachangenotify.sendDataChangeNotify(gameId, userId, TYAssetUtils.getChangeDataNames(rewardAssetList))
            rewardChipCount = TYAssetUtils.getAssetCount(rewardAssetList, hallitem.ASSET_CHIP_KIND_ID)
        states = halldailycheckin.dailyCheckin.getStates(gameId, userId, pktimestamp.getCurrentTimestamp())
        mo = MsgPack()
        mo.setCmd('gain_nslogin_reward')
        mo.setResult('gameId', gameId)
        mo.setResult('userId', userId)
        mo.setResult('rewardstate', TodoTaskHelper.translateDailyCheckinStates(states))
        mo.setResult('success', True)
        mo.setResult('chip', userchip.getChip(userId))
        mo.setResult('rewardchip', rewardChipCount)
        router.sendToUser(mo, userId)

    def _sendMatchSignsToUser(self, userId, gameId, clientId):
        signs = {}
        for roomdef in gdata.roomIdDefineMap().values():
            if roomdef.shadowId == 0 and roomdef.configure.get('ismatch'):
                roomId = roomdef.roomId
                issignin = daobase.executeTableCmd(roomId, 0, 'SISMEMBER', 'signs:' + str(roomId), userId)
                if issignin:
                    signs[roomdef.bigRoomId] = 1
        if signs:
            mo = MsgPack()
            mo.setCmd('m_signs')
            mo.setResult('gameId', gameId)
            mo.setResult('userId', userId)
            mo.setResult('signs', signs)
            router.sendToUser(mo, userId)

    def _sendOnLineInfoToUser(self, userId, gameId, clientId):
        all_count = _ONLINES.get(gameId, 30000)
        if all_count <= 0:
            all_count = 30000
        rate = hallconf.getOnlineUserCountRate(clientId)
        mo = MsgPack()
        mo.setCmd('room_online_info')
        mo.setParam('gameId', gameId)
        mo.setParam('free_count', int(all_count * 0.5 * rate))
        mo.setParam('high_count', int(all_count * 0.3 * rate))
        mo.setParam('match_count', int(all_count * 0.2 * rate))
        mo.setParam('rooms', [])
        router.sendToUser(mo, userId)

    @markCmdActionMethod(cmd='user', action='get_head_pics', clientIdVer=0)
    def doUserGetHeadPics(self, userId, gameId, clientId):
        mo = MsgPack()
        mo.setCmd('get_head_pics')
        mo.setResult('heads', halluser.getUserHeadPics(clientId))
        router.sendToUser(mo, userId)

    @markCmdActionMethod(cmd='user', action='set_star_id', clientIdVer=0)
    def doUserSetStarId(self, userId, gameId, clientId, starId):
        userdata.setAttr(userId, 'starid', starId)
        mo = MsgPack()
        mo.setCmd('set_star_id')
        mo.setResult('gameId', gameId)
        mo.setResult('starId', starId)
        router.sendToUser(mo, userId)

    @markCmdActionMethod(cmd='user', action='todo_task', clientIdVer=0)
    def doUserToDoTask(self):
        msg = runcmd.getMsgPack()
        ftlog.error('NotImplementedError, doUserToDoTask, msg=', msg)
        return runcmd.newOkMsgPack(code=1)

    @markCmdActionMethod(cmd='new_user_reward', action='receive', clientIdVer=0)
    def doNewUserRewardReceive(self, userId, gameId, clientId):
        '''
        领取新手启动资金
        '''
        isSend, startChip, _final = hallstartchip.sendStartChip(userId, gameId, clientId)
        mo = MsgPack()
        mo.setCmd('new_user_reward')
        mo.setResult('action', 'receive')
        mo.setResult('coin', startChip if isSend else 0)
        router.sendToUser(mo, userId)

    @markCmdActionMethod(cmd='sub_member', action='unsub', clientIdVer=0)
    def doUnsubMember(self, userId, isTempVipUser):
        ftlog.info('AccountTcpHandler.doUnsubMember userId=', userId,
                   'isTempVipUser='******'UNSUB_MEMBER', 0)

    @classmethod
    def _doChangeNameCheck(self, userId, clientId):
        canRename, desc = hallrename.checkRename(HALL_GAMEID, userId)
        if canRename:
            return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, TodoTaskRename(desc))
        else:
            info = TodoTaskShowInfo(desc, True)
            if hallrename.payOrder:
                product, _ = hallstore.findProductByPayOrder(HALL_GAMEID, userId, clientId, hallrename.payOrder)
                if product:
                    info.setSubCmd(TodoTaskPayOrder(product))
            return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, info)

    @markCmdActionMethod(cmd='change_name', action='check', clientIdVer=0)
    def doChangeNameCheck(self, userId, clientId):
        self._doChangeNameCheck(userId, clientId)

    @classmethod
    def _doChangeNameTry(self, userId, clientId, newName):
        #         renameConf = hallconf.getClientRenameConf(clientId)
        #         if (renameConf
        #             and not renameConf.get('containsSensitive', 1)
        #             and keywords.isContains(newName)):
        #             info = TodoTaskShowInfo(hallrename.stringRenameContainsSensitive)
        #             return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, info)
        code, info = hallrename.tryRename(HALL_GAMEID, userId, newName)
        if ftlog.is_debug():
            ftlog.debug('hallrename._doChangeNameTry->', code, info)
        if code == -3:
            # name not changed !!
            pass
        elif code == -2:
            # 没有改名卡
            info = TodoTaskShowInfo(hallrename.stringRenameCardRequired, True)
            if hallrename.payOrder:
                product, _ = hallstore.findProductByPayOrder(HALL_GAMEID, userId, clientId, hallrename.payOrder)
                if product:
                    info.setSubCmd(TodoTaskPayOrder(product))
            return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, info)
        elif code == 0:
            # 改名成功
            return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, TodoTaskPopTip(hallrename.stringRenameSuccessed))
        else:
            # SDK改名失败
            return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, TodoTaskPopTip(info))

    @markCmdActionMethod(cmd='change_name', action='try', clientIdVer=0)
    def doChangeNameTry(self, userId, clientId, newName):
        self._doChangeNameTry(userId, clientId, newName)

    @markCmdActionMethod(cmd='five_star_rating', clientIdVer=0)
    def doFiveStarRating(self, userId, clientId):
        fivestarrate.onFiveStarRated(userId, clientId, pktimestamp.getCurrentTimestamp())
Beispiel #3
0
class GameTcpHandler(BaseMsgPackChecker):
    def __init__(self):
        self.helper = UtilHelper()
        
    def _check_param_configKey(self, msg, key, params):
        configKey = msg.getParam(key)
        if not configKey or not isstring(configKey):
            return None, None
        return None, configKey

    @markCmdActionMethod(cmd='game', action="data", clientIdVer=0)
    def doGameData(self, userId, gameId, clientId):
        self.helper.sendUserInfoResponse(userId, gameId, clientId, '', 0, 1)

    @markCmdActionMethod(cmd='game', action="bindPhone", clientIdVer=0)
    def dosendChipToUser(self, userId, gameId, clientId):
        # 添加绑定
        nowBindPone = gamedata.getGameAttr(userId, gameId, 'bindReward1')
        if not nowBindPone or nowBindPone < 1:
            gamedata.setGameAttr(userId, gameId, 'bindReward1', 1)
        else:
            from poker.entity.biz.exceptions import TYBizException
            raise TYBizException(-1, '重复绑定')
        # 发金币
        ftlog.info('cmd game action bindPhone userId =', userId)
        from poker.entity.dao import userchip, daoconst
        userchip.incrChip(userId, gameId, 5000, daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, 'BIND_PHONE', 0, clientId)
        datachangenotify.sendDataChangeNotify(gameId, userId, 'chip')
        # 消息推送
        from poker.entity.biz.message import message
        msg = '恭喜您绑定手机成功,赠送您5000金币'
        message.send(gameId, message.MESSAGE_TYPE_PRIVATE, userId, msg)
        # 更新小红点
        datachangenotify.sendDataChangeNotify(gameId, userId, ['free', 'promotion_loc'])
        TGHall.getEventBus().publishEvent(UserBindPhoneEvent(userId, gameId))
        
    @markCmdActionMethod(cmd='game', action="bindIDCard", clientIdVer=0)
    def dosendBindIDChipToUser(self, userId, gameId, clientId):
        # 添加绑定
        nowBindID = gamedata.getGameAttr(userId, gameId, 'bindIDReward')
        if not nowBindID or nowBindID < 1:
            gamedata.setGameAttr(userId, gameId, 'bindIDReward', 1)
        else:
            from poker.entity.biz.exceptions import TYBizException
            raise TYBizException(-1, '重复绑定')
        
        ftlog.info('cmd game action bindIDCard userId =', userId)
        day2Kind = hallitem.itemSystem.findItemKind(hallitem.ITEM_HERO_KIND_ID)
        userBag = hallitem.itemSystem.loadUserAssets(userId).getUserBag()
        timestamp = pktimestamp.getCurrentTimestamp()
        userBag.addItemUnitsByKind(gameId, day2Kind, 1, timestamp, 0, 'BIND_PHONE', 0)
        datachangenotify.sendDataChangeNotify(gameId, userId, 'item')
        # 消息推送
        from poker.entity.biz.message import message
        msg = '恭喜您绑定身份证成功,赠送您1张英雄帖'
        message.send(gameId, message.MESSAGE_TYPE_PRIVATE, userId, msg)

    @markCmdActionMethod(cmd='game', action="enter", clientIdVer=0)
    def doGameEnter(self, userId, gameId, clientId):
        isdayfirst, iscreate = halluser.loginGame(userId, gameId, clientId)
        self.helper.sendUserInfoResponse(userId, gameId, clientId, '', 0, 1)
        self.helper.sendTodoTaskResponse(userId, gameId, clientId, isdayfirst)
        # BI日志统计
        bireport.userGameEnter(gameId, userId, clientId)
        bireport.reportGameEvent('BIND_GAME',
                                 userId, gameId, 0, 0, 0, 0, 0, 0, [], clientId, iscreate)
        evt = OnLineGameChangedEvent(userId, gameId, 1, clientId)
        TGHall.getEventBus().publishEvent(evt)

    @markCmdActionMethod(cmd='game', action="leave", clientIdVer=0)
    def doGameLeave(self, userId, gameId, clientId):
        evt = OnLineGameChangedEvent(userId, gameId, 0, clientId)
        TGHall.getEventBus().publishEvent(evt)

    @markCmdActionMethod(cmd='game', action='get_member_reward', clientIdVer=0)
    def doGameGetMemberReward(self, userId, gameId, clientId):
        userAssets = hallitem.itemSystem.loadUserAssets(userId)
        userBag = userAssets.getUserBag()
        memberCardItem = userBag.getItemByKindId(hallitem.ITEM_MEMBER_NEW_KIND_ID)
        timestamp = pktimestamp.getCurrentTimestamp()
        if memberCardItem and memberCardItem.canCheckin(timestamp):
            checkinAction = memberCardItem.itemKind.findActionByName('checkin')
            checkinAction.doAction(gameId, userAssets, memberCardItem, timestamp, {})
            datachangenotify.sendDataChangeNotify(gameId, userId, 'free')
            TodoTaskHelper.sendTodoTask(gameId, userId, TodoTaskGoldRain('恭喜您领取了今天的会员福利'))

    @markCmdActionMethod(cmd='game', action='get_exit_remind', clientIdVer=0)
    def doGameGetExitRemind(self, userId, gameId, clientId):
        hall_exit_remind.queryExitRemind(gameId, userId, clientId)
        
    @markCmdActionMethod(cmd='game', action='get_quick_start_recommend', clientIdVer=0)
    def doGetQuickStartRecommend(self, userId, gameId, clientId):
        '''
        获取快速开始推荐
        '''
        hall_quick_start_recommend.queryQuickStartRecommend(userId, gameId, clientId)
        
    @markCmdActionMethod(cmd='game', action='get_exit_plugin_remind', clientIdVer=0)
    def doGetExitPluginRemind(self, userId, gameId, clientId):
        '''
        获取插件退出挽留推荐
        '''
        gameIds = self.getGamesUserCanEnter(userId, gameId, clientId)
        hall_exit_plugin_remind.queryExitPluginRemind(userId, gameId, clientId, gameIds)
        
    @markCmdActionMethod(cmd='game', action='enter_game_after_login', clientIdVer=0)
    def doEnterGameAfterLogin(self, userId, gameId, clientId):
        '''
        获取快速开始推荐
        '''
        gameIds = self.getGamesUserCanEnter(userId, gameId, clientId)
        hall_enter_game_after_login.queryEnterGameAfterLogin(userId, gameId, clientId, gameIds)
       
    @markCmdActionMethod(cmd='game', action='common_config', clientIdVer=0)
    def doGetCommonConfig(self, userId, gameId, clientId, configKey):
        '''
        获取透传给前端的通用配置
        '''
        config = hallconf.getCommonConfig(clientId, configKey)
        msg = MsgPack()
        msg.setCmd('game')
        msg.setResult('action', 'common_config')
        msg.setResult('gameId', gameId)
        msg.setResult('userId', userId)
        msg.setResult('clientId', clientId)
        msg.setResult('configKey', configKey)
        msg.setResult('config', config)
        router.sendToUser(msg, userId)
         
    def getGamesUserCanEnter(self, userId, gameId, clientId):
        '''
        获取用户可以进入那些游戏
        '''
        gameIds = []
        template = hallgamelist2.getUITemplate(gameId, userId, clientId)
        if template is None:
            return gameIds
        _games, pages, innerGames = HallHelper.encodeHallUITemplage2(gameId, userId, clientId, template)
        from hall.servers.util import gamelistipfilter
        _games, _, _ = gamelistipfilter.filtergamelist(3.81, _games, pages, innerGames, userId, clientId)
        
        for game in _games:
            gameId = game.get('gameId', 0)
            if (0 != gameId) and (gameId not in gameIds):
                gameIds.append(gameId)
        
        return gameIds
        
    @markCmdActionMethod(cmd='game', action='get_fangka_item', clientIdVer=0)
    def doGetFangKaItem(self, userId, gameId, clientId):
        hall_fangka.sendFangKaItemToClient(gameId, userId, clientId)
        
    @markCmdActionMethod(cmd='game', action='require_fangka_buy_info', clientIdVer=0)
    def doRequireFangBuyInfo(self, userId, gameId, clientId):
        hall_fangka_buy_info.queryFangKaBuyInfo(gameId, userId, clientId)

    @markCmdActionMethod(cmd='game', action='get_game_update_info', clientIdVer=0)
    def doGameGetUpdateInfo(self, userId, gameId, clientId, version, updateVersion):
        hall_game_update.getUpdateInfo(gameId, userId, clientId, version, updateVersion)

    @markCmdActionMethod(cmd='game', action='update_notify', clientIdVer=0)
    def doGameUpdateNotify(self, userId, gameId, clientId, module):
        '''
        通知前端更新消息
        '''
        from hall.entity.hallconf import HALL_GAMEID
        datachangenotify.sendDataChangeNotify(HALL_GAMEID, userId, module)
        
    @markCmdActionMethod(cmd='game', action='enter_friend_table', clientIdVer=0)
    def doEnterFriendTable(self, userId, gameId, clientId, ftId):
        '''
        通知前端更新消息
        '''
        hall_friend_table.enterFriendTable(userId, gameId, clientId, ftId)
        
    @markCmdActionMethod(cmd='game', action='enter_back_ground', clientIdVer=0)
    def doEnterBackground(self, userId, gameId, clientId):
        '''
        用户退回后台
        '''
        hall_enter_resume_background.enterBackGround(userId, gameId, clientId)
    
    @markCmdActionMethod(cmd='game', action='resume_fore_ground', clientIdVer=0)
    def doResumeForeground(self, userId, gameId, clientId):
        '''
        用户返回前台
        '''
        hall_enter_resume_background.resumeForeGround(userId, gameId, clientId)

    @markCmdActionMethod(cmd='game', action="get_assign_reward", clientIdVer=0)
    def doHallNoticeReward(self, userId, gameId, clientId):
        ftlog.debug("doHallNoticeReward:", userId, gameId, clientId)
        from hall.entity.newpopwnd import noticeReward
        from poker.protocol import runcmd
        msg = runcmd.getMsgPack()
        noticeReward(userId, gameId, clientId, msg)
        if ftlog.is_debug():
            ftlog.debug("hall_notice_reward:", userId, gameId, clientId)
Beispiel #4
0
class AccountTcpHandler(BaseMsgPackChecker):

    
    def __init__(self):
        self.helper = UtilHelper()

    def _check_param_newName(self, msg, key, params):
        newName = msg.getParam(key)
        if not newName or not isstring(newName):
            return 'Error param newName', None
        return None, newName
    
    def _check_param_msg(self, msg, key, params):
        msgstr = msg.getParam(key)
        if not msgstr or not isstring(msgstr):
            return 'Error param msg', None
        return None, msgstr
    
    def _check_param_ismgr(self, msg, key, params):
        ismgr = msg.getParam(key)
        if ismgr in (0, 1):
            return None, ismgr
        return 'Error param ismgr', None

    def _check_param_scope(self, msg, key, params):
        scope = msg.getParam(key)
        if not scope or not isstring(scope):
            return None, 'hall'
        return None, scope
    
    def _check_param_clientIds(self, msg, key, params):
        clientIds = msg.getParam(key)
        if not clientIds:
            return None, []
        return None, clientIds
    
    def _check_param_isTempVipUser(self, msg, key, params):
        isTempVipUser = msg.getParam(key, 0)
        if isTempVipUser in (0, 1):
            return None, isTempVipUser
        return 'Error param isTempVipUser', None
    
    def _check_param_clipboardContent(self, msg, key, params):
        value = msg.getParam(key, '')
        return None, value
    
    def _check_param_isStopServer(self, msg, key, params):
        isStopServer = msg.getParam(key)
        if not isinstance(isStopServer, bool):
            return 'Error param isStopServer', None
        return None, isStopServer
    
    def checkForceLogout(self, userId):
        '''
        检查是否运行登录
        '''
        if halluser.isForceLogout(userId) :
            onlines.forceLogOut(userId, '')
            return 1
        return 0


    def recoverUserTableChips(self, userId, clientId):
        try:
            tableChips = userchip.getTableChipsAll(userId)
            ftlog.debug('recoverUserTableChips->', tableChips)
            datas = None
            if isinstance(tableChips, dict):
                datas = tableChips
            elif isinstance(tableChips, list):
                datas = {}
                for x in xrange(len(tableChips) / 2):
                    datas[tableChips[x * 2]] = tableChips[x * 2 + 1]
            delTablesIds = []
            for tableId, tchip in datas.items():
                tableId, tchip = strutil.parseInts(tableId, tchip)
                troomId = strutil.getTableRoomId(tableId)
                if not troomId or troomId <= 0:
                    delTablesIds.append(tableId)
                    continue
                gameId, _, _, _ = strutil.parseInstanceRoomId(troomId)
                if not gameId or gameId <= 0:
                    delTablesIds.append(tableId)
                    continue
                seatId = 0
                try:
                    seatId, _ = roommgr.doCheckUserLoc(userId, gameId, troomId, tableId, clientId)
                except:
                    delTablesIds.append(tableId)
                    ftlog.error()
                    continue
    
                if not seatId:
                    userchip.moveAllTableChipToChip(userId, gameId, 'TABLE_TCHIP_TO_CHIP', troomId, clientId, tableId)
                    delTablesIds.append(tableId)
                else:
                    # the user is on the table , do not clear
                    pass
    
            if delTablesIds:
                userchip.delTableChips(userId, delTablesIds)
        except:
            ftlog.error()


    @markCmdActionMethod(cmd='user', action='info', clientIdVer=0)
    def doUserInfo_0(self, userId):
        '''
        低版本不允许登录了
        '''
        onlines.forceLogOut(userId, '')


    @markCmdActionMethod(cmd='user', action='info', clientIdVer=3.0)
    def doUserInfo_3(self, userId, gameId, clientId, isFirstuserInfo):
        # 检查是否禁止登录
        if self.checkForceLogout(userId) :
            return
        
        self.updateBiggestHallVersion(userId, gameId, clientId)
        
        loc = ''
        if isFirstuserInfo :
            self._sendLocalStaticInfo(userId)
            loc = onlinedata.checkUserLoc(userId, clientId, 0)
            self.recoverUserTableChips(userId, clientId)
        # 发送udata和gdata响应消息
        self.helper.sendUserInfoResponse(userId, gameId, clientId, loc, 1, 1)

    def _sendLocalStaticInfo(self, userId):
        mo = hallversionmgr.makeStaticMessage()
        router.sendToUser(mo, userId)


    @markCmdActionMethod(cmd='user', action='info', clientIdVer=3.3)
    def doUserInfo_3_3(self, userId, gameId, clientId, isFirstuserInfo):
        # 检查是否禁止登录
        if self.checkForceLogout(userId) :
            return
        
        self.updateBiggestHallVersion(userId, gameId, clientId)

        loc = ''
        if isFirstuserInfo :
            loc = onlinedata.checkUserLoc(userId, clientId, 0)
            self.recoverUserTableChips(userId, clientId)
        # 发送udata响应消息
        self.helper.sendUserInfoResponse(userId, gameId, clientId, loc, 1, 0)
        
    def updateBiggestHallVersion(self, userId, gameId, clientId):
        '''
        记录更新该用户最高的版本号
        '''
        if gameId != HALL_GAMEID:
            return 
        
        _, clientVer, _ = strutil.parseClientId(clientId)
        if not clientVer:
            return
        
        bVer = 1.0
        biggestClientIdStr = gamedata.getGameAttr(userId, gameId, 'biggestHallVer')
        if biggestClientIdStr:
            bVer = float(biggestClientIdStr)
        
        if clientVer > bVer:
            gamedata.setGameAttr(userId, gameId, 'biggestHallVer', str(clientVer))
            ftlog.debug('update user biggest hallVersion:', clientVer)
        

    @markCmdActionMethod(cmd='user', action='bind', clientIdVer=0)
    def doUserBind_0(self, userId, gameId, clientId, isFirstuserInfo, clipboardContent):
        if ftlog.is_debug():
            ftlog.debug('AccountTcpHandler.doUserBind_0',
                        'userId=', userId,
                        'clipboard=', clipboardContent)
        
        # 检查是否禁止登录
        if self.checkForceLogout(userId) :
            return
        
        self.updateBiggestHallVersion(userId, gameId, clientId)
        
        loc = ''
        if isFirstuserInfo :
            loc = onlinedata.checkUserLoc(userId, clientId, 0)
            self.recoverUserTableChips(userId, clientId)
#         # 更新基本信息
        #halluser.updateUserBaseInfo(userId, clientId, runcmd.getMsgPack())
        clipboard = Clipboard.parse(clipboardContent)
        # 登录游戏处理
        isdayfirst, isCreate = halluser.loginGame(userId, gameId, clientId, clipboard)
        # 发送udata和gdata响应消息
        self.helper.sendUserInfoResponse(userId, gameId, clientId, loc, 1, 1)
        # 发送TodoTask消息
        self.helper.sendTodoTaskResponse(userId, gameId, clientId, isdayfirst)
        
        # 分析clipboardConent内容,根据分析结果 功能 
        TGHall.getEventBus().publishEvent(EventAfterUserLogin(userId, gameId, isdayfirst, isCreate, clientId, loc, clipboard))

        # 标记游戏时长开始
        gamedata.incrPlayTime(userId, 0, gameId)
        # BI日志统计
        bireport.userBindUser(gameId, userId, clientId)
        bireport.reportGameEvent('BIND_USER',
                                 userId, gameId, 0, 0, 0, 0, 0, 0, [], clientId)
        evt = OnLineGameChangedEvent(userId, gameId, 1, clientId)
        TGHall.getEventBus().publishEvent(evt)


    def _isReconnect(self, userId, gameId, clientId, loc):
        if loc:
            locList = loc.split(':')
            for subLoc in locList:
                if subLoc != '0.0.0.0':
                    return True
        return False
        
    @markCmdActionMethod(cmd='user', action='bind', clientIdVer=3.3)
    def doUserBind_3_3(self, userId, gameId, clientId, isFirstuserInfo, clipboardContent):
        # 检查是否禁止登录
        if self.checkForceLogout(userId) :
            return

        self.updateBiggestHallVersion(userId, gameId, clientId)
        
        loc = ''
        isReconnect = False
        if isFirstuserInfo :
            loc = onlinedata.checkUserLoc(userId, clientId, 0)
            self.recoverUserTableChips(userId, clientId)
            isReconnect = self._isReconnect(userId, gameId, clientId, loc)
#         # 更新基本信息
#         halluser.updateUserBaseInfo(userId, clientId, runcmd.getMsgPack())
        clipboard = Clipboard.parse(clipboardContent)
        # 登录游戏处理
        isdayfirst, isCreate = halluser.loginGame(userId, gameId, clientId, clipboard)
        # 发送udata响应消息
        self.helper.sendUserInfoResponse(userId, gameId, clientId, loc, 1, 0)
        # 发送gdata响应消息
        self.helper.sendUserInfoResponse(userId, gameId, clientId, loc, 0, 1)
        # 发送响应消息
        if not isReconnect:
            self.helper.sendTodoTaskResponse(userId, gameId, clientId, isdayfirst)
        
        # 分析clipboardConent内容,根据分析结果 功能 
        TGHall.getEventBus().publishEvent(EventAfterUserLogin(userId, gameId, isdayfirst, isCreate, clientId, loc, clipboard))    
            
        # 标记游戏时长开始
        gamedata.incrPlayTime(userId, 0, gameId)
        # BI日志统计
        bireport.userBindUser(gameId, userId, clientId)
        bireport.reportGameEvent('BIND_USER',
                                 userId, gameId, 0, 0, 0, 0, 0, 0, [], clientId)

        evt = OnLineGameChangedEvent(userId, gameId, 1, clientId)
        TGHall.getEventBus().publishEvent(evt)


    @markCmdActionMethod(cmd='user', action='heart_beat', clientIdVer=0)
    def doUserHeartBeat(self, userId, gameId, clientId, isMust):
        hallled.doSendLedToUser(userId)
        clientIdVer = strutil.parseClientId(clientId)[1]
        if clientIdVer < 3.0:  # c++老版本斗地主才需要在heart_beat时下发m_signs 
            self._sendMatchSignsToUser(userId, gameId, clientId)
        self._sendOnLineInfoToUser(userId, gameId, clientId)

        if ftlog.is_debug():
            ftlog.debug("user|heart_beat", userId, gameId, clientId)
        from hall.entity import hallnewnotify
        hallnewnotify.pushNotify(userId, gameId, clientId)
        
    @markCmdActionMethod(cmd='user', action='sync_timestamp', clientIdVer=0)
    def doUserTimestamp(self, userId, gameId, clientId, isMust):
        '''
        同步服务器时间
        '''
        msg = MsgPack()
        msg.setCmd('user')
        msg.setResult('action', 'sync_timestamp')
        msg.setResult('gameId', gameId)
        msg.setResult('userId', userId)
        msg.setResult('current_ts', pktimestamp.getCurrentTimestamp())
        router.sendToUser(msg, userId)

    @markCmdActionMethod(cmd='send_led', clientIdVer=0, lockParamName='send_led')
    def doSendLed(self, gameId, msg, ismgr, scope='hall', clientIds=[], isStopServer=False):
        hallled.sendLed(gameId, msg, ismgr, scope, clientIds, isStopServer)
        
    @markCmdActionMethod(cmd='gain_nslogin_reward', clientIdVer=0)
    def doGainNSLoginReward(self, userId, gameId, clientId):
        checkinOk, rewardAssetList, _checkinDays = \
            halldailycheckin.dailyCheckin.gainCheckinReward(gameId, userId)
        rewardChipCount = 0
        if checkinOk:
            datachangenotify.sendDataChangeNotify(gameId, userId, TYAssetUtils.getChangeDataNames(rewardAssetList))
            rewardChipCount = TYAssetUtils.getAssetCount(rewardAssetList, hallitem.ASSET_CHIP_KIND_ID)
        states = halldailycheckin.dailyCheckin.getStates(gameId, userId, pktimestamp.getCurrentTimestamp())
        mo = MsgPack()
        mo.setCmd('gain_nslogin_reward')
        mo.setResult('gameId', gameId)
        mo.setResult('userId', userId)
        mo.setResult('rewardstate', TodoTaskHelper.translateDailyCheckinStates(states))
        mo.setResult('success', True)
        mo.setResult('chip', userchip.getChip(userId))
        mo.setResult('rewardchip', rewardChipCount)
        router.sendToUser(mo, userId)
        
    def _sendMatchSignsToUser(self, userId, gameId, clientId):
        signs = {}
        for roomdef in gdata.roomIdDefineMap().values() :
            if roomdef.shadowId == 0 and roomdef.configure.get('ismatch') :
                roomId = roomdef.roomId
                issignin = daobase.executeTableCmd(roomId, 0, 'SISMEMBER', 'signs:' + str(roomId), userId)
                if issignin :
                    signs[roomdef.bigRoomId] = 1
        if signs :
            mo = MsgPack()
            mo.setCmd('m_signs')
            mo.setResult('gameId', gameId)
            mo.setResult('userId', userId)
            mo.setResult('signs', signs)
            router.sendToUser(mo, userId)


    def _sendOnLineInfoToUser(self, userId, gameId, clientId):
        all_count = _ONLINES.get(gameId, 30000)
        if all_count <= 0 :
            all_count = 30000
        rate = hallconf.getOnlineUserCountRate(clientId)
        mo = MsgPack()
        mo.setCmd('room_online_info')
        mo.setResult('gameId', gameId)
        mo.setResult('free_count', int(all_count * 0.5 * rate))
        mo.setResult('high_count', int(all_count * 0.3 * rate))
        mo.setResult('match_count', int(all_count * 0.2 * rate))
        mo.setResult('rooms', [])
        # 兼容
        mo.setParam('gameId', gameId)
        mo.setParam('free_count', int(all_count * 0.5 * rate))
        mo.setParam('high_count', int(all_count * 0.3 * rate))
        mo.setParam('match_count', int(all_count * 0.2 * rate))
        mo.setParam('rooms', [])
        router.sendToUser(mo, userId)


    @markCmdActionMethod(cmd='user', action='get_head_pics', clientIdVer=0)
    def doUserGetHeadPics(self, userId, gameId, clientId):
        mo = MsgPack()
        mo.setCmd('get_head_pics')
        mo.setResult('heads', halluser.getUserHeadPics(clientId))
        router.sendToUser(mo, userId)


    @markCmdActionMethod(cmd='user', action='set_star_id', clientIdVer=0)
    def doUserSetStarId(self, userId, gameId, clientId, starId):
        userdata.setAttr(userId, 'starid', starId)
        mo = MsgPack()
        mo.setCmd('set_star_id')
        mo.setResult('gameId', gameId)
        mo.setResult('starId', starId)
        router.sendToUser(mo, userId)


    @markCmdActionMethod(cmd='user', action='todo_task', clientIdVer=0)
    def doUserToDoTask(self):
        msg = runcmd.getMsgPack()
        ftlog.error('NotImplementedError, doUserToDoTask, msg=', msg)
        return runcmd.newOkMsgPack(code=1)

    @markCmdActionMethod(cmd='new_user_reward', action='receive', clientIdVer=0)
    def doNewUserRewardReceive(self, userId, gameId, clientId):
        '''
        领取新手启动资金
        '''
        isSend, startChip, _final = hallstartchip.sendStartChip(userId, gameId, clientId)
        mo = MsgPack()
        mo.setCmd('new_user_reward')
        mo.setResult('action', 'receive')
        mo.setResult('coin', startChip if isSend else 0)
        router.sendToUser(mo, userId)
    
    @markCmdActionMethod(cmd='sub_member', action='unsub', clientIdVer=0)
    def doUnsubMember(self, userId, isTempVipUser):
        ftlog.info('AccountTcpHandler.doUnsubMember userId=', userId,
                   'isTempVipUser='******'UNSUB_MEMBER', 0)
    
    @classmethod
    def _doChangeNameCheck(self, userId, clientId):
        canRename, desc = hallrename.checkRename(HALL_GAMEID, userId)
        if canRename:
            return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, TodoTaskRename(desc))
        else:
            info = TodoTaskShowInfo(desc, True)
            if hallrename.payOrder:
                product, _ = hallstore.findProductByPayOrder(HALL_GAMEID, userId, clientId, hallrename.payOrder)
                if product:
                    info.setSubCmd(TodoTaskPayOrder(product))
            return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, info)
            
    @markCmdActionMethod(cmd='change_name', action='check', clientIdVer=0)
    def doChangeNameCheck(self, userId, clientId):
        self._doChangeNameCheck(userId, clientId)
    
    @classmethod
    def _doChangeNameTry(self, userId, clientId, newName):
#         renameConf = hallconf.getClientRenameConf(clientId)
#         if (renameConf
#             and not renameConf.get('containsSensitive', 1)
#             and keywords.isContains(newName)):
#             info = TodoTaskShowInfo(hallrename.stringRenameContainsSensitive)
#             return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, info)
        code, info = hallrename.tryRename(HALL_GAMEID, userId, newName)
        if ftlog.is_debug():
            ftlog.debug('hallrename._doChangeNameTry->', code, info)

        CLIENT_VER = 4.57
        _, clientVer, _ = strutil.parseClientId(clientId)

        if ftlog.is_debug():
            ftlog.debug("_doChangeNameTry clientVer", userId, clientId, newName, code, info, clientVer)

        reInfo = ""
        if code == -3 :
            reInfo = "昵称没有变化"
        elif code == -2 :
            # 没有改名卡
            info = TodoTaskShowInfo(hallrename.stringRenameCardRequired, True)
            if hallrename.payOrder:
                product, _ = hallstore.findProductByPayOrder(HALL_GAMEID, userId, clientId, hallrename.payOrder)
                if product:
                    info.setSubCmd(TodoTaskPayOrder(product))
            return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, info)
        elif code == 0 :
            reInfo = "昵称修改成功"
            # 改名成功
            if clientVer < CLIENT_VER:
                if ftlog.is_debug():
                    ftlog.debug("_doChangeNameTry ok", userId, clientId, newName, code, info, clientVer)
                return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, TodoTaskPopTip(hallrename.stringRenameSuccessed))
        else:
            #reInfo = "修改昵称失败,请重试"
            reInfo = info
            # SDK改名失败
            if clientVer < CLIENT_VER:
                if ftlog.is_debug():
                    ftlog.debug("_doChangeNameTry fail", userId, clientId, newName, code, info, clientVer)
                return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, TodoTaskPopTip(info))
                    
        mo = MsgPack()
        mo.setCmd('change_name')
        mo.setResult('action', 'try')
        mo.setResult('userId', userId)
        mo.setResult('code', code)
        mo.setResult('reInfo', reInfo)
        router.sendToUser(mo, userId)
        if ftlog.is_debug():
            ftlog.debug("_doChangeNameTry result",userId, clientId, newName, code, reInfo)
    @markCmdActionMethod(cmd='change_name', action='try', clientIdVer=0)
    def doChangeNameTry(self, userId, clientId, newName):
        self._doChangeNameTry(userId, clientId, newName)
    
    @markCmdActionMethod(cmd='five_star_rating', clientIdVer=0)
    def doFiveStarRating(self, userId, clientId):
        fivestarrate.onFiveStarRated(userId, clientId, pktimestamp.getCurrentTimestamp())
    
    def _doCashGetCash(self, gameId, userId, clientId):
        mo = MsgPack()
        mo.setCmd('cash')
        mo.setResult('action', 'get_cash')
        mo.setResult('gameId', gameId)
        mo.setResult('userId', userId)
        msg = runcmd.getMsgPack()
        try:
            wxappId = msg.getParam('wxappId')
            value = msg.getParam('value')
            if not isstring(wxappId):
                raise TYBizException(-1, 'wxappId参数错误')
            if not isinstance(value, int) or value <= 0:
                raise TYBizException(-1, 'value参数错误')
            mo.setResult('value', value)
            hallexchange.requestExchangeCash(userId, value, wxappId, pktimestamp.getCurrentTimestamp())
        except TYBizException, e:
            ftlog.error('AccountTcpHandler._doCashGetCash',
                        'userId=', userId,
                        'clientId=', clientId,
                        'msg=', msg.pack())
            mo.setResult('code', e.errorCode)
            mo.setResult('info', e.message)
        router.sendToUser(mo, userId)