Beispiel #1
0
def __initializeTables(gdatas):
    '''
    初始化所有的桌子对象
    '''
    if _DEBUG:
        debug('initializeTables begin')
    srvid = gdata.serverId()
    roomids = gdata.srvIdRoomIdListMap().get(srvid, None)
    if roomids:
        allrooms = gdata.roomIdDefineMap()
        tyrooms = gdata.rooms()
        for roomid in roomids:
            room = tyrooms[roomid]
            roomdefine = allrooms[roomid]
            gameins = gdata.games()[roomdefine.gameId]
            if _DEBUG:
                debug('initializeTables roomid=', roomid, 'tableCount=',
                      roomdefine.tableCount)
            if roomdefine.tableCount > 0:
                baseid = roomid * 10000 + 1
                for x in xrange(roomdefine.tableCount):
                    tableid = baseid + x
                    tableins = gameins.newTable(room, tableid)
                    assert (isinstance(tableins, TYTable))
                    room.maptable[tableid] = tableins
    if _DEBUG:
        debug('initializeTables end')
Beispiel #2
0
    def sendMsgTableInfo(self, msg, userId, seatId, isReconnect, isHost=False):
        """用户坐下后给用户发送table_info"""
        if msg and msg.getParam('itemParams', None):
            self.__init_params = msg.getParam('itemParams', None)
            self.__params_desc = self.get_select_create_config_items()
            self.__params_play_desc = self.get_select_create_config_items(True)
            ftlog.debug('MajiangFriendTable.sendMsgTableInfo userId:', userId,
                        ' seatId:', seatId, ' message:', msg, ' itemParams:',
                        self.__init_params)
            ftId = msg.getParam('ftId', None)
            if ftId:
                self.processCreateTableSetting()
                self.__ftId = ftId
                # 保存自建桌对应关系
                CreateTableData.addCreateTableNo(self.tableId, self.roomId,
                                                 gdata.serverId(), self.ftId)

                self.__table_owner = userId
                self.__table_owner_seatId = seatId
                self.logic_table.tableConfig[MFTDefine.FTID] = self.__ftId
                self.logic_table.tableConfig[MFTDefine.FTOWNER] = userId
                self.logic_table.tableConfig[
                    MFTDefine.ITEMPARAMS] = self.__init_params
                self.logic_table.tableConfig[
                    MFTDefine.CREATE_TABLE_DESCS] = self.__params_desc
                self.logic_table.tableConfig[
                    MFTDefine.
                    CREATE_TABLE_PLAY_DESCS] = self.__params_play_desc
                # 返回房主建房成功消息,准备状态
                self.logic_table.playerReady(self.getSeatIdByUserId(userId),
                                             True)
                self.logic_table.msgProcessor.create_table_succ_response(
                    userId, self.getSeatIdByUserId(userId), 'ready', 1,
                    self.logic_table.getBroadCastUIDs())

                # 房主启动准备定时器,超时解散牌桌
                message = self.logic_table.msgProcessor.getMsgReadyTimeOut()
                readyTimeOut = self.getTableConfig(MFTDefine.READY_TIMEOUT,
                                                   3600)
                ftlog.debug(
                    'MajiangFriendTable.sendMsgTableInfo begin to check ready timeout, message:',
                    message, ' readyTimeOut:', readyTimeOut,
                    ' tableOwnerSeatId:', self.tableOwnerSeatId)
                self.tableTimer.setupTimer(self.tableOwnerSeatId, readyTimeOut,
                                           message)
                self.__ready_time_out_timer = True
        # 发送table_info
        super(MajiangFriendTable,
              self).sendMsgTableInfo(msg, userId, seatId, isReconnect,
                                     userId == self.__table_owner)
        # 如果正在投票解散,给用户补发投票解散的消息
        if self.logic_table.isFriendTablePlaying(
        ) and self.voteHost != MTDefine.INVALID_SEAT:
            # 补发投票解散信息
            self.logic_table.msgProcessor.create_table_dissolve_vote(
                self.players[self.voteHost].userId, self.voteHost,
                self.maxSeatN, self.get_leave_vote_info(),
                self.get_leave_vote_info_detail(),
                self.logic_table.player[self.voteHost].name,
                self.__vote_time_out, self.logic_table.getBroadCastUIDs())
Beispiel #3
0
def _initializeTables(gdatas):
    '''
    初始化所有的桌子对象
    '''
    if _DEBUG:
        debug('initializeTables begin')
    srvid = gdata.serverId()
    roomids = gdata.srvIdRoomIdListMap().get(srvid, None)  # 获取所有房间ids
    if roomids:
        allrooms = gdata.roomIdDefineMap()  # 房间定义映射
        tyrooms = gdata.rooms()  # 所有房间实例字典
        for roomid in roomids:
            room = tyrooms[roomid]
            roomdefine = allrooms[roomid]
            gameins = gdata.games()[roomdefine.gameId]  # 房间游戏实例TYGame
            if _DEBUG:
                debug('initializeTables roomid=', roomid, 'tableCount=',
                      roomdefine.tableCount)
            if roomdefine.tableCount > 0:  # 桌子数
                baseid = roomid * 10000 + 1  # 桌子开始的id
                for x in xrange(roomdefine.tableCount):
                    tableid = baseid + x
                    tableins = gameins.newTable(room, tableid)  # 创建桌子
                    room.maptable[tableid] = tableins  # 桌子映射实例
    if _DEBUG:
        debug('initializeTables end')
Beispiel #4
0
def __initializeTables(gdatas):
    '''
    初始化所有的桌子对象
    '''
    if _DEBUG:
        debug('initializeTables begin')
    srvid = gdata.serverId()
    roomids = gdata.srvIdRoomIdListMap().get(srvid, None)
    if roomids:
        allrooms = gdata.roomIdDefineMap()
        tyrooms = gdata.rooms()
        for roomid in roomids:
            room = tyrooms[roomid]
            roomdefine = allrooms[roomid]
            gameins = gdata.games()[roomdefine.gameId]
            if _DEBUG:
                debug('initializeTables roomid=', roomid, 'tableCount=', roomdefine.tableCount)
            if roomdefine.tableCount > 0:
                baseid = roomid * 10000 + 1
                for x in xrange(roomdefine.tableCount):
                    tableid = baseid + x
                    tableins = gameins.newTable(room, tableid)
                    assert (isinstance(tableins, TYTable))
                    room.maptable[tableid] = tableins
    if _DEBUG:
        debug('initializeTables end')
Beispiel #5
0
def tcpUserOnline(userCount, *arglist, **argdict):
    '''
    用户TCP连接在线数量的标准本地日志文件汇报和REDIS实时数据汇报
    '''
    bidata.setConnOnLineInfo(gdata.serverId(), userCount)
    alist = ['tcp_user_online', 0, userCount]
    alist.extend(arglist)
    _report(alist, argdict)
Beispiel #6
0
def _getRpcDstServerId(rsrv, groupId):
    if groupId <= 0:
        if rsrv.srvType == gdata.serverType():
            return gdata.serverId()
        groupId = rsrv.sididx
        rsrv.sididx += 1
    dst = rsrv.sids[groupId % rsrv.sidlen]
    return dst
Beispiel #7
0
def initialize():
    global _inited, grandPrizePoolInst
    if not _inited:
        _inited = True
        serverId = gdata.serverId()
        if serverId == "CT9999000001":
            grandPrizePoolInst = GrandPrizePool()
            ftlog.debug("GrandPrizePool, init grandPrizePoolInst", serverId)
Beispiel #8
0
def _checkLastedConnId(userId):
    if gdata.ENABLIE_DEFENCE_2:
        try:
            from poker.entity.dao import sessiondata
            from poker.servers.conn.rpc import onlines
            lastConnId = sessiondata.getConnId(userId)
            if lastConnId and lastConnId != gdata.serverId():
                onlines.forceLogOut2(userId, lastConnId, '')
        except:
            ftlog.error()
Beispiel #9
0
    def sendMsgTableInfo(self, msg, userId, seatId, isReconnect, isHost=False):
        """用户坐下后给用户发送table_info"""
        if msg and msg.getParam('itemParams', None):
            self.__init_params = msg.getParam('itemParams', None)
            self.__params_desc = self.get_select_create_config_items()
            self.__params_play_desc = self.get_select_create_config_items(True)
            ftlog.debug('MajiangFriendTable.sendMsgTableInfo userId:', userId
                        , ' seatId:', seatId
                        , ' message:', msg
                        , ' itemParams:', self.__init_params
                        )
            ftId = msg.getParam('ftId', None)
            if ftId:
                self.processCreateTableSetting()
                self.__ftId = ftId
                # 保存自建桌对应关系
                CreateTableData.addCreateTableNo(self.tableId, self.roomId, gdata.serverId(), self.ftId)

                self.__table_owner = userId
                self.__table_owner_seatId = seatId
                self.logic_table.tableConfig[MFTDefine.FTID] = self.__ftId
                self.logic_table.tableConfig[MFTDefine.FTOWNER] = userId
                self.logic_table.tableConfig[MFTDefine.ITEMPARAMS] = self.__init_params
                self.logic_table.tableConfig[MFTDefine.CREATE_TABLE_DESCS] = self.__params_desc
                self.logic_table.tableConfig[MFTDefine.CREATE_TABLE_PLAY_DESCS] = self.__params_play_desc
                # 返回房主建房成功消息,准备状态
                self.logic_table.playerReady(self.getSeatIdByUserId(userId), True)
                self.logic_table.msgProcessor.create_table_succ_response(userId
                                                                         , self.getSeatIdByUserId(userId)
                                                                         , 'ready'
                                                                         , 1
                                                                         , self.logic_table.getBroadCastUIDs())

                # 房主启动准备定时器,超时解散牌桌
                message = self.logic_table.msgProcessor.getMsgReadyTimeOut()
                readyTimeOut = self.getTableConfig(MFTDefine.READY_TIMEOUT, 3600)
                ftlog.debug('MajiangFriendTable.sendMsgTableInfo begin to check ready timeout, message:', message
                            , ' readyTimeOut:', readyTimeOut
                            , ' tableOwnerSeatId:', self.tableOwnerSeatId)
                self.tableTimer.setupTimer(self.tableOwnerSeatId, readyTimeOut, message)
                self.__ready_time_out_timer = True
        # 发送table_info
        super(MajiangFriendTable, self).sendMsgTableInfo(msg, userId, seatId, isReconnect, userId == self.__table_owner)
        # 如果正在投票解散,给用户补发投票解散的消息
        if self.logic_table.isFriendTablePlaying() and self.voteHost != MTDefine.INVALID_SEAT:
            # 补发投票解散信息
            self.logic_table.msgProcessor.create_table_dissolve_vote(self.players[self.voteHost].userId
                                                                     , self.voteHost
                                                                     , self.maxSeatN
                                                                     , self.get_leave_vote_info()
                                                                     , self.get_leave_vote_info_detail()
                                                                     , self.logic_table.player[self.voteHost].name
                                                                     , self.__vote_time_out
                                                                     , self.logic_table.getBroadCastUIDs())
Beispiel #10
0
 def __init__(self):
     super(MajiangRobotManager, self).__init__()
     baseSnsId = 'robot:' + gdata.serverId()
     users = []
     for index in range(resource.getRobotCount()):
         robot = resource.getRobot(index)
         name = robot['name']
         snsId = baseSnsId + '_' + str(index)
         users.append(RobotUser(None, snsId, name)) 
     self.freeRobotUsers = users
     ftlog.debug('robot user count ->', len(users))
Beispiel #11
0
 def __init__(self):
     super(MajiangRobotManager, self).__init__()
     baseSnsId = 'robot:' + gdata.serverId()
     users = []
     for index in range(resource.getRobotCount()):
         robot = resource.getRobot(index)
         name = robot['name']
         snsId = baseSnsId + '_' + str(index)
         users.append(RobotUser(None, snsId, name))
     self.freeRobotUsers = users
     ftlog.debug('robot user count ->', len(users))
Beispiel #12
0
def _report(arglist, argdict, isHinfo=0):
    if _ENABLE_BIFILE:
        global _BILOGER
        if _BILOGER is None:
            log_file_fullpath = gdata.globalConfig()['log_path']
            log_file_fullpath = log_file_fullpath + '/bi.' + gdata.serverId() + '.log'
            _BILOGER = ftlog.openNormalLogfile(log_file_fullpath)
        jsondata = [timestamp.formatTimeMs(), gdata.serverId()]
        jsondata.extend(arglist)
        jsondata.append(argdict)
        msg = strutil.dumps(jsondata)
        _BILOGER.info(msg)
    else:
        jsondata = ['BIREPORT', gdata.serverId()]
        jsondata.extend(arglist)
        jsondata.append(argdict)
        msg = strutil.dumps(jsondata)
        if isHinfo:
            ftlog.hinfo(msg)
        else:
            ftlog.info(msg)
Beispiel #13
0
 def __init__(self):
     super(DizhuRobotManager, self).__init__()
     res = loadResource('robot_info.json')
     rinfo = strutil.loads(res)
     baseSnsId = rinfo['basesnsid'] + gdata.serverId()
     users = []
     names = rinfo["names"]
     for x in xrange(len(names)):
         name = names[x]
         snsId = baseSnsId + '_' + str(x)
         users.append(RobotUser(None, snsId, name))
     self.freeRobotUsers = users
     ftlog.debug('robot user count ->', len(users))
Beispiel #14
0
    def isOtherGameServer(cls, gameId):
        '''判断是否为别的游戏的GR/GT,如果是,不加载当前游戏的 plugins'''
        serverType, serverId = gdata.serverType(), gdata.serverId()
        if serverType not in (gdata.SRV_TYPE_ROOM, gdata.SRV_TYPE_TABLE):
            return False

        if '-' in serverId:
            serverGameId = int(serverId.split('-')[0][2:])
        elif serverType == gdata.SRV_TYPE_ROOM:
            serverGameId = int(serverId[2:-4])
        elif serverType == gdata.SRV_TYPE_TABLE:
            serverGameId = int(serverId[2:-7])
        return serverGameId != gameId
Beispiel #15
0
    def isOtherGameServer(cls, gameId):
        '''判断是否为别的游戏的GR/GT,如果是,不加载当前游戏的 plugins'''
        serverType, serverId = gdata.serverType(), gdata.serverId()
        if serverType not in (gdata.SRV_TYPE_ROOM, gdata.SRV_TYPE_TABLE):
            return False

        if '-' in serverId:
            serverGameId = int(serverId.split('-')[0][2:])
        elif serverType == gdata.SRV_TYPE_ROOM:
            serverGameId = int(serverId[2:-4])
        elif serverType == gdata.SRV_TYPE_TABLE:
            serverGameId = int(serverId[2:-7])
        return serverGameId != gameId
Beispiel #16
0
def _getRpcId():
    targs = ftsvr.getTaskRunArg()
    rpcid = targs.get('rpcid', None)
    if not rpcid:
        rpcid = targs.get('userheader1', None)
        if rpcid and rpcid.find('RPC.') == 0:
            targs['rpcid'] = rpcid
        else:
            global _RPC_ID_COUNT_
            _RPC_ID_COUNT_ += 1
            rpcid = 'RPC.' + gdata.serverId() + '.' + str(_RPC_ID_COUNT_)
            targs['rpcid'] = rpcid
    return rpcid
Beispiel #17
0
    def initGame(self):
        from difang.majiang2.entity import majiang_account
        self._account = majiang_account
        serverType = gdata.serverType()

        if serverType == gdata.SRV_TYPE_ROBOT:
            self._robotmgr = MajiangRobotManager()
            globalEventBus.subscribe(EventHeartBeat, self._robotmgr.onHeartBeat)

        elif (serverType == gdata.SRV_TYPE_TABLE) or (serverType == gdata.SRV_TYPE_ROOM):
            CreateTableData.initialize(gdata.serverId())  # 初始化创建牌桌数据模块
            MJCreateTableRecord.initialize()  # 初始化自建桌战绩模块
        elif serverType == gdata.SRV_TYPE_CENTER:
            pass
Beispiel #18
0
    def initGame(self):
        from majiang2.entity import majiang_account
        self._account = majiang_account
        serverType = gdata.serverType()

        if serverType == gdata.SRV_TYPE_ROBOT :
            self._robotmgr = MajiangRobotManager()
            globalEventBus.subscribe(EventHeartBeat, self._robotmgr.onHeartBeat)
            
        elif (serverType == gdata.SRV_TYPE_TABLE) or (serverType == gdata.SRV_TYPE_ROOM):
            CreateTableData.initialize(gdata.serverId())                # 初始化创建牌桌数据模块
            MJCreateTableRecord.initialize()                            # 初始化自建桌战绩模块
        elif serverType == gdata.SRV_TYPE_CENTER:
            pass
Beispiel #19
0
def _initialize():
    return  # 当前没有做数据缓存,无需数据变化通知

    if gdata.serverType() != gdata.SRV_TYPE_UTIL:
        return

    channelcount = 16
    channels = []
    usids = gdata.serverTypeMap()[gdata.SRV_TYPE_UTIL]
    usids.sort()
    if len(usids) < channelcount:
        if usids[0] == gdata.serverId():
            for x in xrange(channelcount):
                channels.append('userdatachange_%d' % (x))
    else:
        if gdata.serverId() in usids:
            i = usids.index(gdata.serverId())
            if i < channelcount:
                channels.append('userdatachange_%d' % (i))

    if channels:
        conf = config.redis_config_map.get('mix')
        ip, port = conf[0], conf[1]
        subscribe.startSubScriber(ip, port, channels, _onSubMessage)
Beispiel #20
0
def _initialize():
    return  # 当前没有做数据缓存,无需数据变化通知

    if gdata.serverType() != gdata.SRV_TYPE_UTIL:
        return

    channelcount = 16
    channels = []
    usids = gdata.serverTypeMap()[gdata.SRV_TYPE_UTIL]
    usids.sort()
    if len(usids) < channelcount:
        if usids[0] == gdata.serverId():
            for x in xrange(channelcount):
                channels.append('userdatachange_%d' % (x))
    else:
        if gdata.serverId() in usids:
            i = usids.index(gdata.serverId())
            if i < channelcount:
                channels.append('userdatachange_%d' % (i))

    if channels:
        conf = config.redis_config_map.get('mix')
        ip, port = conf[0], conf[1]
        subscribe.startSubScriber(ip, port, channels, _onSubMessage)
Beispiel #21
0
def reloadConfig(event):
    global _inited, grandPrizePoolInst
    if not _inited or not grandPrizePoolInst:
        return

    if "game:44:grandPrize:0" not in event.keylist:
        ftlog.info("GrandPrizePool, no need reload config!", event.keylist)
        return

    serverId = gdata.serverId()
    if serverId == "CT9999000001":
        if grandPrizePoolInst:
            # grandPrizePoolInst.dumpGrandPrizePool()
            grandPrizePoolInst.reloadConf()

    ftlog.info("GrandPrizePool, reloadConfig on UT9999000001", serverId)
Beispiel #22
0
    def __init__(self, gameId):
        super(DiFangRobotManager, self).__init__()
        res = loadResource('robot_info.json')
        rinfo = strutil.loads(res)
        baseSnsId = rinfo['basesnsid'] + gdata.serverId()
        users = []
        names = ["rb_" + str(gameId) + "_" + str(uid) for uid in xrange(MAX_ROBOT_UID)]
        # names = ["rb_" + str(uid + 1) for uid in xrange(MAX_ROBOT_UID)]
        #         names = rinfo["names"]
        for x in xrange(len(names)):
            name = names[x]
            snsId = baseSnsId + '_' + str(gameId) + "_" + str(x)
            users.append(gdata.games()[gameId].RobotUserClass(None, snsId, name))
        self.freeRobotUsers = users

        ftlog.info('>> |gameId, robot user count:', gameId, len(users), caller=self)
Beispiel #23
0
    def clearTable(self, sendLeave):
        # 纪录最后一局日志和结束日志
        seats = self.logic_table.getSeats()
        if self.logic_table.tableConfig[
                MFTDefine.CUR_ROUND_COUNT] == self.logic_table.tableConfig[
                    MFTDefine.ROUND_COUNT]:
            if len(self.logic_table.tableResult.results) > 0:
                roundResult = self.logic_table.tableResult.results[-1]
                deltaScore = roundResult.score
                totalScore = self.logic_table.tableResult.score
                curRound = self.logic_table.tableConfig[
                    MFTDefine.CUR_ROUND_COUNT]
                totalRound = self.logic_table.tableConfig[
                    MFTDefine.ROUND_COUNT]
                ftlog.debug('MajiangFriendTable.cleraTable stat tableNo',
                            self.ftId, 'seats', seats, 'deltaScore:',
                            deltaScore, 'totalScore:', totalScore, 'gameId:',
                            self.gameId, 'roomId:', self.roomId, 'tableId',
                            self.tableId)
                hall_friend_table.addOneResult(self.ftId, seats, deltaScore,
                                               totalScore, curRound,
                                               totalRound, self.gameId,
                                               self.roomId, self.tableId)
            else:
                ftlog.debug(
                    'MajiangFriendTable.cleraTable CUR_ROUND_COUNT',
                    self.logic_table.tableConfig[MFTDefine.CUR_ROUND_COUNT],
                    'ROUND_COUNT',
                    self.logic_table.tableConfig[MFTDefine.ROUND_COUNT])

        # def gameEnd(tableNo, seats, totalScore, totalRound, gameId, roomId, tableId)
        if self.logic_table.tableConfig[MFTDefine.CUR_ROUND_COUNT] > 0:
            totalScore = self.logic_table.tableResult.score
            if not totalScore:
                totalScore = [0 for _ in range(self.logic_table.playerCount)]
            totalRound = self.logic_table.tableConfig[MFTDefine.ROUND_COUNT]
            ftlog.debug('MajiangFriendTable.cleraTable stat gameEnd tableNo:',
                        self.ftId, 'seats:', seats, 'totalScore:', totalScore,
                        'totalRound:', totalRound, 'gameId:', self.gameId,
                        'roomId:', self.roomId, 'tableId:', self.tableId)
            hall_friend_table.gameEnd(self.ftId, seats, totalScore, totalRound,
                                      self.gameId, self.roomId, self.tableId)
        """清理桌子"""
        super(MajiangFriendTable, self).clearTable(sendLeave)
        # 释放大厅房间ID
        hall_friend_table.releaseFriendTable(self.gameId, self.ftId)
        CreateTableData.removeCreateTableNo(gdata.serverId(), self.ftId)
Beispiel #24
0
 def initGameAfter(self):
     """
     此方法由系统进行调用
     游戏初始化的后处理
     """
     serverType = gdata.serverType()
     if serverType == gdata.SRV_TYPE_TABLE:
         roomIds = gdata.srvIdRoomIdListMap().get(gdata.serverId(), None)
         if roomIds:
             from freetime.core.timer import FTLoopTimer
             from newfish.servers.room.rpc import room_remote
             allRooms = gdata.roomIdDefineMap()
             for roomId in roomIds:
                 ctrlRoomId = allRooms[roomId].parentId
                 tableCount = allRooms[roomId].tableCount
                 # 目前GR、GT是同时启动,GT启动完成时,GR不一定启动完成,所以暂时延后调用
                 FTLoopTimer(3, 0, room_remote.initializedGT, ctrlRoomId,
                             roomId, tableCount).start()
Beispiel #25
0
def _handlerRpcCommand(msg):
    '''
    处理接收到的一个远程RPC调用
    '''
    t1 = time()
    if performance.PERFORMANCE_NET:
        netkey = msg.getKey(performance.NET_KEY)
        if netkey:
            netkey.append(gdata.serverId())
            netkey.append('DO')
            netkey.append(float('%0.4f' % t1))
    try:
        rpc = msg.getKey('rpc')
        argl = msg.getKey('argl')
        argd = msg.getKey('argd')
        markParams = _runenv._rpc_methods.get(rpc, None)
        ret = _invokeMethodLocked(markParams, argl, argd)
        if markParams['syncCall']:
            if performance.PERFORMANCE_NET:
                netkey = msg.getKey(performance.NET_KEY)
                if not netkey:
                    netkey = []
                mo = strutil.dumps({'ret': ret,
                                    performance.NET_KEY: netkey})
            else:
                mo = strutil.dumps({'ret': ret})
            router.responseQurery(mo)
    except Exception, e:
        ftlog.error('_handlerRpcCommand msg=', msg)
        try:
            if router.isQuery():
                targs = ftsvr.getTaskRunArg()
                if not targs.get('responsed'):
                    if performance.PERFORMANCE_NET:
                        netkey = msg.getKey(performance.NET_KEY)
                        if not netkey:
                            netkey = []
                        mo = strutil.dumps({'ex': '_handlerRpcCommand Exception : ' + str(e),
                                            performance.NET_KEY: netkey})
                    else:
                        mo = strutil.dumps({'ex': '_handlerRpcCommand Exception : ' + str(e)})
                    router.responseQurery(mo)
        except:
            ftlog.error()
Beispiel #26
0
def __initializeRooms(gdatas):
    '''
    初始化所有的房间对象
    '''
    if _DEBUG:
        debug('initializeRooms begin')
    from poker.entity.game.rooms import getInstance
    srvid = gdata.serverId()
    roomids = gdata.srvIdRoomIdListMap().get(srvid, None)
    if roomids:
        tyrooms = {}
        gdatas['tyrooms.instance.dict'] = tyrooms
        allrooms = gdata.roomIdDefineMap()
        for roomid in roomids:
            roomdefine = allrooms[roomid]
            roomins = getInstance(roomdefine)
            assert (isinstance(roomins, TYRoom))
            tyrooms[roomid] = roomins
        gdatas['tyrooms.instance.dict'] = makeReadonly(tyrooms)
    if _DEBUG:
        debug('initializeRooms end')
Beispiel #27
0
def __initializeRooms(gdatas):
    '''
    初始化所有的房间对象
    '''
    if _DEBUG:
        debug('initializeRooms begin')
    from poker.entity.game.rooms import getInstance
    srvid = gdata.serverId()
    roomids = gdata.srvIdRoomIdListMap().get(srvid, None)
    if roomids:
        tyrooms = {}
        gdatas['tyrooms.instance.dict'] = tyrooms
        allrooms = gdata.roomIdDefineMap()
        for roomid in roomids:
            roomdefine = allrooms[roomid]
            roomins = getInstance(roomdefine)
            assert (isinstance(roomins, TYRoom))
            tyrooms[roomid] = roomins
        gdatas['tyrooms.instance.dict'] = makeReadonly(tyrooms)
    if _DEBUG:
        debug('initializeRooms end')
Beispiel #28
0
    def clearTable(self, sendLeave):
        # 纪录最后一局日志和结束日志
        seats = self.logic_table.getSeats()
        if self.logic_table.tableConfig[MFTDefine.CUR_ROUND_COUNT] == self.logic_table.tableConfig[
            MFTDefine.ROUND_COUNT]:
            if len(self.logic_table.tableResult.results) > 0:
                roundResult = self.logic_table.tableResult.results[-1]
                deltaScore = roundResult.score
                totalScore = self.logic_table.tableResult.score
                curRound = self.logic_table.tableConfig[MFTDefine.CUR_ROUND_COUNT]
                totalRound = self.logic_table.tableConfig[MFTDefine.ROUND_COUNT]
                ftlog.debug('MajiangFriendTable.cleraTable stat tableNo', self.ftId, 'seats', seats, 'deltaScore:',
                            deltaScore, 'totalScore:', totalScore, 'gameId:', self.gameId, 'roomId:', self.roomId,
                            'tableId', self.tableId)
                hall_friend_table.addOneResult(self.ftId, seats, deltaScore, totalScore, curRound, totalRound,
                                               self.gameId, self.roomId, self.tableId)
            else:
                ftlog.debug('MajiangFriendTable.cleraTable CUR_ROUND_COUNT',
                            self.logic_table.tableConfig[MFTDefine.CUR_ROUND_COUNT],
                            'ROUND_COUNT',
                            self.logic_table.tableConfig[MFTDefine.ROUND_COUNT])

        # def gameEnd(tableNo, seats, totalScore, totalRound, gameId, roomId, tableId)
        if self.logic_table.tableConfig[MFTDefine.CUR_ROUND_COUNT] > 0:
            totalScore = self.logic_table.tableResult.score
            if not totalScore:
                totalScore = [0 for _ in range(self.logic_table.playerCount)]
            totalRound = self.logic_table.tableConfig[MFTDefine.ROUND_COUNT]
            ftlog.debug('MajiangFriendTable.cleraTable stat gameEnd tableNo:', self.ftId, 'seats:', seats,
                        'totalScore:', totalScore, 'totalRound:', totalRound,
                        'gameId:', self.gameId, 'roomId:', self.roomId,
                        'tableId:', self.tableId)
            hall_friend_table.gameEnd(self.ftId, seats, totalScore, totalRound, self.gameId, self.roomId, self.tableId)

        """清理桌子"""
        super(MajiangFriendTable, self).clearTable(sendLeave)
        # 释放大厅房间ID
        hall_friend_table.releaseFriendTable(self.gameId, self.ftId)
        CreateTableData.removeCreateTableNo(gdata.serverId(), self.ftId)
Beispiel #29
0
def _initializeRooms(gdatas):
    '''
    初始化所有的房间对象
    '''
    if _DEBUG:
        debug('initializeRooms begin')
    from poker.entity.game.rooms import getInstance  # 获取房间实例
    srvid = gdata.serverId()
    roomids = gdata.srvIdRoomIdListMap().get(srvid, None)  # 获取所有房间ids
    if _DEBUG:
        debug('initializeRooms srvid=', srvid, 'roomids=', roomids)
    if roomids:
        tyrooms = {}
        gdatas['tyrooms.instance.dict'] = tyrooms  # 房间实例dict
        allrooms = gdata.roomIdDefineMap()  # 房间定义的映射
        if _DEBUG:
            debug('initializeRooms allroomsid=', allrooms.keys())
        for roomid in roomids:
            roomdefine = allrooms[roomid]
            roomins = getInstance(roomdefine)  # 房间实例子
            tyrooms[roomid] = roomins  # 房间id: 实例
        gdatas['tyrooms.instance.dict'] = makeReadonly(tyrooms)
    if _DEBUG:
        debug('initializeRooms end')
Beispiel #30
0
    def initGame(self):
        from hall.entity import hallaccount
        self._account = hallaccount  # 大厅的账户处理类
        serverType = gdata.serverType()

        if serverType == gdata.SRV_TYPE_CENTER:
            centers = gdata.serverTypeMap().get(gdata.SRV_TYPE_CENTER, [])[:]
            centers.sort()
            sid = gdata.serverId()
            inits = gdata.centerServerLogics().get(sid, [])
            # 轮盘开奖信息的监听
            from hall.servers.center.rpc.roulette_remote import sendReward
            globalEventBus.subscribe(EventHeartBeat, sendReward)
            if inits:
                for pkg in inits:
                    ftlog.info('init center logic of ->', pkg)
                    exec 'from %s import _initialize; _initialize(1)' % (pkg)

        if serverType == gdata.SRV_TYPE_UTIL:
            from hall.servers.util.account_handler import updateOnLineInfos
            globalEventBus.subscribe(EventHeartBeat, updateOnLineInfos)
            # 在线信息初始化, ONLIE处理必须在UTIL服务
            from hall.entity import hallonline
            hallonline._initialize()

        if serverType == gdata.SRV_TYPE_TABLE or serverType == gdata.SRV_TYPE_ROOM:
            from hall.servers.room.room import reportRoomOnlineInfos
            globalEventBus.subscribe(EventHeartBeat, reportRoomOnlineInfos)
            from hall.entity import hallchatlog
            hallchatlog._initialize()

        # 注意: 各个模块间有先后初始化的顺序
        from hall.entity import hallitem, hallstore, hallvip, hallbenefits, \
            hallranking, hallshare, hallpromote, hallfree, hallgamelist, hallgamelist2, \
            halldailycheckin, hallmenulist, hallcoupon, hallmoduletip, \
            hallrename, hallads, hallflipcardluck, hallpopwnd, hallstartchip, \
            fivestarrate, match360kp, neituiguang, hallstocklimit, \
            hall_first_recharge, hallroulette, hallled, hall_exit_remind
        from hall.entity.hallactivity import activity
        from hall.entity.halltmpact import tmp_activity
        from hall.entity.hall_red_envelope import hall_red_envelope

        # 道具初始化
        hallitem._initialize()
        # 限购初始化
        hallstocklimit._initialize()
        # 商城初始化
        hallstore._initialize()
        # VIP系统初始化
        hallvip._initialize()
        # 救济金系统初始化
        hallbenefits._initialize()
        # 用户初始基金初始化
        hallstartchip._initialize()
        halldailycheckin._initialize()
        # 排行榜
        hallranking._initialize(0)
        # 活动系统初始化
        activity._initialize()
        hallcoupon._initialize()
        hallshare._initialize()
        hallgamelist._initialize()
        hallgamelist2._initialize()
        hallmenulist._initialize()
        hallrename._initialize()
        hallmoduletip._initialize()
        hallads._initialize()
        hallflipcardluck._initialize()
        hallpopwnd._initialize()
        hallpromote._initialize()
        hallfree._initialize()
        fivestarrate._initialize()
        match360kp._initialize()
        neituiguang._initialize()

        from hall.entity import halltask
        halltask.initialize()

        # 默认配置初始化
        hallmoduledefault._initialize()
        halllocalnotification._initialize()
        # 首冲礼包配置
        hall_first_recharge._initialize()
        tmp_activity._initialize()
        # 红包模块配置初始化
        hall_red_envelope._initialize()
        # 钻石抽奖初始化
        hallroulette._initialize()
        # led配置初始化
        hallled._initializeConfig()
        # 退出提醒
        hall_exit_remind._initialize()
        # 三方控制模块开关
        hall_third_sdk_switch._initialize()
        # 域名配置初始化
        halldomains._initialize()
        # 插件升级模块初始化
        hall_game_update._initialize()
        # 登录奖励模块初始化
        hall_login_reward._initialize()
        # 道具转换模块初始化
        hall_item_exchange._initialize()
        # 自建桌房间号初始化
        hall_friend_table._initialize()
        # 小推广系统初始化
        from hall.entity import hall_simple_invite
        hall_simple_invite.initialize()
        # 房卡购买提示信息模块初始化
        from hall.entity import hall_fangka_buy_info
        hall_fangka_buy_info._initialize()
Beispiel #31
0
    def reload(cls,
               gameId,
               handler_name='',
               handler_names=[],
               handlers_config=None):
        '''
        reload 某个 gameId 的插件

        @handlers_names: 指定要reload哪些plugin。不指定就reload所有(plugins越来越多,会比较慢)

        不管有没有指定 reload 哪些插件,都会重新 build 事件表。
        为什么不优化为只处理指定的plugins的事件?
        没有必要,性能瓶颈不在这,而且全部重新build一定不会出问题,而且的而且,那样做会增加复杂性。
        '''

        if not cls.needLoadPlugin():
            ftlog.info('reload >> |this type of server not need load plugin',
                       '|serverId, gameId:',
                       gdata.serverId(),
                       gameId,
                       caller=cls)
            return

        if cls.isOtherGameServer(gameId):
            ftlog.info('reload >> |',
                       'do not reload in other game GR/GT',
                       '|serverId, gameId:',
                       gdata.serverId(),
                       gameId,
                       caller=cls)
            return

        if not handlers_config:
            handlers_config = configure.getGameJson(gameId, 'plugins', {})
            if not handlers_config:
                return
                # handlers_config = dict([(hc['name'], hc) for hc in handlers_config])
        handlers_config_dict = dict([(hc['name'], hc)
                                     for hc in handlers_config['handlers']])
        ftlog.info('<< |', cls.plugins, handlers_config, caller=cls)

        if handler_name:
            handler_names = [handler_name]

        handlers_config_list = []  # to be reload
        cls.map_events[gameId] = {}  # 事件表
        if handler_names:
            for handler_name in handler_names:
                if handler_name in handlers_config_dict:
                    handlers_config_list.append(
                        handlers_config_dict.get(handler_name))
                if handler_name in cls.plugins[gameId]:
                    del cls.plugins[gameId][handler_name]
        else:
            handlers_config_list = handlers_config['handlers']
            cls.plugins[gameId] = {}  # plugins 表

        # 先 reload modules
        plugins = cls.plugins[gameId]
        reloadPlugins = []
        for cfg in handlers_config_list:
            try:
                plugin = TYPlugin(gameId, cfg)
                if plugin.handlers:
                    plugins[cfg['name']] = plugin
                    reloadPlugins.append(plugin)
            except Exception as e:
                ftlog.exception(e)

        cls.buildEventMap(gameId, plugins, handlers_config,
                          cls.map_events[gameId])

        ftlog.info("TYPluginCenter.reload | "
                   "reloadPlugins:", [plugin.name for plugin in reloadPlugins])

        # onReload 时可能会有阻塞操作而让出CPU, 这时有可能会产生新的事件
        # 如果在 onReload 后才 buildEventMap,则这个事件会丢(因为eventMap在build之前是空的)
        # 所以,把 onReload 移到 build Event Map 之后
        for plugin in reloadPlugins:
            try:
                plugin.onReload()
            except Exception as e:
                ftlog.exception(e)
Beispiel #32
0
def doCleanUpEmptyTcp(event):
    '''
    检查当前进程内的空闲的TCP链接, 
    关闭空闲的TCP, 释放资源
    '''
    if event.count % _EMPTY_TCP_CHECK_TIMES != 0:
        return
    ftlog.debug('doCleanUpEmptyTcp->', event.count)
    # 空连接检测
    emptyCount = 0
    for protocol in _NEW_PROTOCOLS:
        cnt = protocol.timeOutCount + 1
        if cnt > _EMPTY_TCP_TIMEOUT_COUNT:
            _sendLogOutMsg(protocol, ERROR_SYS_LOGOUT_TIME_OUT, 1)
            emptyCount = emptyCount + 1
        else:
            protocol.timeOutCount = cnt

    # 客户端心跳检测,视为断开链接
    count = 0
    rcount = 0
    closeUser = []
    for uid in _ONLINE_USERS:
        user = _ONLINE_USERS[uid]
        if user.userId > 10000:  # 机器人永远不掉线
            tcpProtocol = user.tcpProtocol
            if tcpProtocol and tcpProtocol.userId > 0:
                cnt = user.hbcounter + 1
                if cnt > _EMPTY_USER_TIMEOUT_COUNT:
                    closeUser.append(uid)
                    ftlog.debug(
                        'doCleanUpEmptyTcp heart beat time out ! user.userId=',
                        user.userId)
                    user.hbcounter = 0
                else:
                    user.hbcounter = cnt
                    count = count + 1
        else:
            tcpProtocol = user.tcpProtocol
            if tcpProtocol and tcpProtocol.userId > 0:
                rcount = rcount + 1

    for uid in closeUser:
        if uid in _ONLINE_USERS:
            user = _ONLINE_USERS[uid]
            _sendLogOutMsg(user.tcpProtocol, ERROR_SYS_LOGOUT_TIME_OUT, 1)

    bireport.tcpUserOnline(count)

    ftlog.warn('online user count=', count, 'robots=', rcount, \
               'ONLINE_USERS=', len(_ONLINE_USERS), 'NEW_PROTOCOLS=', len(_NEW_PROTOCOLS), \
               'close empty tcp=', emptyCount, 'close user ='******'SERVERID=', gdata.serverId())
Beispiel #33
0
    def _doUserConnect(self, userId, gameId, clientId):
        """
        更新用户的TCP链接
        """
        ftlog.info('doUpdateUserTcpConnection userId=', userId, 'address=',
                   self.clientAddress)
        ipaddress = self.transport.getPeer().host
        if ftlog.is_debug():
            ftlog.debug("|userId, ip:", userId, ipaddress, caller=self)
        if userId <= 0:
            _sendLogOutMsg(self, ERROR_SYS_LOGOUT_USERID_ERROR, 1)
            return
        # try:
        #             conns = gdata.getUserConnIpPortList()
        #             idx = userId % len(conns)
        #             if idx != gdata.serverNumIdx() :
        #                 raise Exception('the user ip port error, this is ' + str(gdata.serverNumIdx()) \
        #                                 + ' idx=' + str(idx) + ' sid=' + str(gdata.serverId()) + ' ' \
        #                                 + str(userId) + ' ' + str(gameId) + ' ' + str(clientId) + ' ' + str(ipaddress))
        #         except:
        #             ftlog.error()
        #             _sendLogOutMsg(self, ERROR_SYS_LOGOUT_TIME_OUT, 1)
        #             return

        intClientId = pokerconf.clientIdToNumber(clientId)
        if intClientId <= 0:
            ftlog.warn('the user clientid error ! ' + str(userId) + ' ' + \
                       str(gameId) + ' ' + str(clientId) + ' ' + str(ipaddress))
            _sendLogOutMsg(self, ERROR_SYS_LOGOUT_CLIENTID_ERROR, 1)
            return

        _checkLastedConnId(userId)
        session = {'ip': ipaddress, 'ci': clientId, 'conn': gdata.serverId()}
        try:
            if not userdata.checkUserData(userId, clientId, session=session):
                # 冷数据导入失败, 关闭连接TCP连接
                _sendLogOutMsg(self, ERROR_SYS_LOGOUT_DATASWAP_ERROR, 0)
                return
        except:
            # 冷数据导入失败, 关闭连接TCP连接
            ftlog.error()
            _sendLogOutMsg(self, ERROR_SYS_LOGOUT_DATASWAP_ERROR, 0)
            return

        if ftlog.is_debug():
            from poker.entity.dao import sessiondata
            ftlog.debug("|userId, ip:",
                        userId,
                        sessiondata.getClientIp(userId),
                        caller=self)

        # 建立当前进程内的userid和tcp链接的对应关系 1:1的对应关系
        user = None
        if _ONLINE_USERS.has_key(userId):
            user = _ONLINE_USERS[userId]
            user.hbcounter = 0
        else:
            user = TcpUser(userId)
            _ONLINE_USERS[userId] = user
        oldProtocol = user.tcpProtocol
        user.tcpProtocol = self
        user.clientId = str(clientId)
        user.cid = '{"clientId":"' + user.clientId + '",'
        user.gameId = gameId
        self.userId = userId

        if self in _NEW_PROTOCOLS:
            del _NEW_PROTOCOLS[self]

        ftlog.info('User Protocol update : userId=', userId, ' newProtocol=',
                   self.clientAddress)

        _notifyUserOnlineStatus(user, 1)

        if oldProtocol and oldProtocol.userId > 0 and self != oldProtocol:
            ftlog.info('User Protocol close old : userId=', userId,
                       ' oldProtocol=', oldProtocol.clientAddress)
            user.firstUserInfo = 0
            oldProtocol.userId = 0
            _sendLogOutMsg(oldProtocol, ERROR_SYS_LOGOUT_OTHER_LOGIN, 0)
            # TODO 还需要发出room_leave的消息么?
        return 1
Beispiel #34
0
    def reload(cls, gameId, handler_name='', handler_names=[], handlers_config=None):
        '''
        reload 某个 gameId 的插件

        @handlers_names: 指定要reload哪些plugin。不指定就reload所有(plugins越来越多,会比较慢)

        不管有没有指定 reload 哪些插件,都会重新 build 事件表。
        为什么不优化为只处理指定的plugins的事件?
        没有必要,性能瓶颈不在这,而且全部重新build一定不会出问题,而且的而且,那样做会增加复杂性。
        '''

        if not cls.needLoadPlugin():
            ftlog.info('reload >> |this type of server not need load plugin',
                       '|serverId, gameId:', gdata.serverId(), gameId, caller=cls)
            return

        if cls.isOtherGameServer(gameId):
            ftlog.info('reload >> |', 'do not reload in other game GR/GT',
                       '|serverId, gameId:', gdata.serverId(), gameId, caller=cls)
            return

        if not handlers_config:
            handlers_config = configure.getGameJson(gameId, 'plugins', {})
            if not handlers_config:
                return
                # handlers_config = dict([(hc['name'], hc) for hc in handlers_config])
        handlers_config_dict = dict([(hc['name'], hc) for hc in handlers_config['handlers']])
        ftlog.info('<< |', cls.plugins, handlers_config, caller=cls)

        if handler_name:
            handler_names = [handler_name]

        handlers_config_list = []  # to be reload
        cls.map_events[gameId] = {}  # 事件表
        if handler_names:
            for handler_name in handler_names:
                if handler_name in handlers_config_dict:
                    handlers_config_list.append(handlers_config_dict.get(handler_name))
                if handler_name in cls.plugins[gameId]:
                    del cls.plugins[gameId][handler_name]
        else:
            handlers_config_list = handlers_config['handlers']
            cls.plugins[gameId] = {}  # plugins 表

        # 先 reload modules
        plugins = cls.plugins[gameId]
        reloadPlugins = []
        for cfg in handlers_config_list:
            try:
                plugin = TYPlugin(gameId, cfg)
                if plugin.handlers:
                    plugins[cfg['name']] = plugin
                    reloadPlugins.append(plugin)
            except Exception as e:
                ftlog.exception(e)

        cls.buildEventMap(gameId, plugins, handlers_config, cls.map_events[gameId])

        ftlog.info("TYPluginCenter.reload | "
                   "reloadPlugins:", [plugin.name for plugin in reloadPlugins])

        # onReload 时可能会有阻塞操作而让出CPU, 这时有可能会产生新的事件
        # 如果在 onReload 后才 buildEventMap,则这个事件会丢(因为eventMap在build之前是空的)
        # 所以,把 onReload 移到 build Event Map 之后
        for plugin in reloadPlugins:
            try:
                plugin.onReload()
            except Exception as e:
                ftlog.exception(e)
Beispiel #35
0
def _invokeRpcMethod(markParams, argl, argd):
    '''
    进程内其它方法调用RPC方法的代理方法
    '''
    rpc = markParams['rpc']
    rpcSrvType = markParams['rpcSrvType']
    groupIndex = markParams['groupIndex']
    future = markParams['future']
    groupVal = 0
    dstSid = None
    if rpcSrvType == RPC_FIRST_SERVERID:
        dstSid = argl[0]
    else:
        if groupIndex >= 0:
            groupVal = argl[groupIndex]
        if rpcSrvType == gdata.SRV_TYPE_UTIL:
            dstSid = _getRpcDstServerId(router._utilServer, groupVal)
        elif rpcSrvType == gdata.SRV_TYPE_ROOM:
            dstSid = getRpcDstRoomServerId(groupVal, 1)
        elif rpcSrvType == gdata.SRV_TYPE_TABLE:
            dstSid = getRpcDstRoomServerId(groupVal, 0)
        elif rpcSrvType == gdata.SRV_TYPE_CONN:
            dstSid = _getRpcDstServerId(router._connServer, groupVal)
        elif rpcSrvType == gdata.SRV_TYPE_HTTP:
            dstSid = _getRpcDstServerId(router._httpServer, groupVal)
        elif rpcSrvType == gdata.SRV_TYPE_ROBOT:
            dstSid = _getRpcDstServerId(router._robotServer, groupVal)
        elif rpcSrvType == gdata.SRV_TYPE_AGENT:
            dstSid = _getRpcDstServerId(router._agentServer, groupVal)
        elif rpcSrvType == gdata.SRV_TYPE_SDK_HTTP:
            dstSid = _getRpcDstServerId(router._sdkHttpServer, groupVal)
        elif rpcSrvType == gdata.SRV_TYPE_SDK_GATEWAY:
            dstSid = _getRpcDstServerId(router._gatewayHttpServer, groupVal)
        elif rpcSrvType == gdata.SRV_TYPE_CENTER:
            for dst, logics in gdata.centerServerLogics().items():
                if groupVal in logics:
                    dstSid = dst
                    break
            if not dstSid:
                dstSid = router._centerServer.sids[0]

    if not dstSid:
        raise RpcException('RpcException ' + rpc + '! can not location the target server, rpcSrvType=' + str(
            rpcSrvType) + ' groupVal=' + str(groupVal))

    rpcid = _getRpcId()
    if dstSid == gdata.serverId():
        if markParams['syncCall']:
            if future:
                # TODO: Future RPC CALL 1
                return _FutureResultLocal(markParams, argl, argd)
            else:
                ret = _invokeMethodLocked(markParams, argl, argd)
                return strutil.cloneData(ret)
        else:
            ftt = FTLoopTimer(0.01, 0, _invokeMethodLocked, markParams, argl, argd)
            ftt.start()
            return None

    mi = strutil.dumps({'cmd': _runenv._CMD_RPC_,
                        'rpc': rpc,
                        'argl': argl,
                        'argd': argd
                        })

    if markParams['syncCall']:
        if future:
            # TODO: Future RPC CALL 1
            return _FutureResultRemote(rpc, dstSid, mi, rpcid, str(groupVal), _runenv._RPC_TIME_OUT)
        else:
            try:
                jstr = wrapper.query(dstSid, mi, rpcid, str(groupVal), _runenv._RPC_TIME_OUT)
            except FTMsgPackException, e:
                raise e
            except Exception, e:
                ftlog.warn('RpcException msg=', mi)
                raise RpcException('RpcException ' + rpc + ' ! query remote false, ' + str(e))
            return _parseRpcResult(mi, jstr, rpc)
Beispiel #36
0
    def initGame(self):
        from hall.entity import hallaccount
        self._account = hallaccount  # 大厅的账户处理类
        serverType = gdata.serverType()

        if serverType == gdata.SRV_TYPE_CENTER:
            centers = gdata.serverTypeMap().get(gdata.SRV_TYPE_CENTER, [])[:]
            centers.sort()
            sid = gdata.serverId()
            inits = gdata.centerServerLogics().get(sid, [])
            # 轮盘开奖信息的监听
            from hall.servers.center.rpc.roulette_remote import sendReward
            globalEventBus.subscribe(EventHeartBeat, sendReward)
            if inits:
                for pkg in inits:
                    ftlog.info('init center logic of ->', pkg)
                    exec 'from %s import _initialize; _initialize(1)' % (pkg)

        if serverType == gdata.SRV_TYPE_UTIL:
            from hall.servers.util.account_handler import updateOnLineInfos
            globalEventBus.subscribe(EventHeartBeat, updateOnLineInfos)
            # 在线信息初始化, ONLIE处理必须在UTIL服务
            from hall.entity import hallonline
            hallonline._initialize()

        if serverType == gdata.SRV_TYPE_TABLE or serverType == gdata.SRV_TYPE_ROOM:
            from hall.servers.room.room import reportRoomOnlineInfos
            globalEventBus.subscribe(EventHeartBeat, reportRoomOnlineInfos)
            from hall.entity import hallchatlog
            hallchatlog._initialize()

        # 注意: 各个模块间有先后初始化的顺序
        from hall.entity import hallitem, hallstore, hallvip, hallbenefits, \
            hallranking, hallshare, hallpromote, hallfree, hallgamelist, hallgamelist2, \
            halldailycheckin, hallmenulist, hallcoupon, hallmoduletip, \
            hallrename, hallads, hallflipcardluck, hallpopwnd, hallstartchip, \
            fivestarrate, match360kp, neituiguang, hallstocklimit, \
            hall_first_recharge, hallroulette, hallled, hall_exit_remind
        from hall.entity.hallactivity import activity
        from hall.entity.halltmpact import tmp_activity
        from hall.entity.hall_red_envelope import hall_red_envelope

        # 道具初始化
        hallitem._initialize()
        # 限购初始化
        hallstocklimit._initialize()
        # 商城初始化
        hallstore._initialize()
        # VIP系统初始化
        hallvip._initialize()
        # 救济金系统初始化
        hallbenefits._initialize()
        # 用户初始基金初始化
        hallstartchip._initialize()
        halldailycheckin._initialize()
        # 排行榜
        hallranking._initialize(0)
        # 活动系统初始化
        activity._initialize()
        hallcoupon._initialize()
        hallshare._initialize()
        hallgamelist._initialize()
        hallgamelist2._initialize()
        hallmenulist._initialize()
        hallrename._initialize()
        hallmoduletip._initialize()
        hallads._initialize()
        hallflipcardluck._initialize()
        hallpopwnd._initialize()
        hallpromote._initialize()
        hallfree._initialize()
        fivestarrate._initialize()
        match360kp._initialize()
        neituiguang._initialize()

        from hall.entity import halltask
        halltask.initialize()

        # 默认配置初始化
        hallmoduledefault._initialize()
        halllocalnotification._initialize()
        # 首冲礼包配置
        hall_first_recharge._initialize()
        tmp_activity._initialize()
        # 红包模块配置初始化
        hall_red_envelope._initialize()
        # 钻石抽奖初始化
        hallroulette._initialize()
        # led配置初始化
        hallled._initializeConfig()
        # 退出提醒
        hall_exit_remind._initialize()
        # 三方控制模块开关
        hall_third_sdk_switch._initialize()
        # 域名配置初始化
        halldomains._initialize()
        # 插件升级模块初始化
        hall_game_update._initialize()
        # 登录奖励模块初始化
        hall_login_reward._initialize()
        # 道具转换模块初始化
        hall_item_exchange._initialize()
        # 自建桌房间号初始化
        hall_friend_table._initialize()
        # 小推广系统初始化
        from hall.entity import hall_simple_invite
        hall_simple_invite.initialize()
        # 房卡购买提示信息模块初始化
        from hall.entity import hall_fangka_buy_info
        hall_fangka_buy_info._initialize()
Beispiel #37
0
def _main():
    ftlog.info('zzzzzz', gdata.serverId())  # GT0044001_999
    ftlog.info(
        'zzzzzz', gdata.srvIdRoomIdListMap()
    )  # {'GT0044001_999': [441011001, 441021001, 441031001, 441041001, 443011001, 443021001, 444021001, 444031001, 444041001, 444051001, 444111001, 444121001, 444141001, 444151001, 444991001, 445011001, 446011001]}
    ftlog.info('zzzzzz', gdata.allServersMap())