Beispiel #1
0
 def sendMsg(cls, msg, uidList):
     """
     发送消息给客户端
     """
     if not isinstance(uidList, list):
         uidList = [uidList]
     router.sendToUsers(msg, uidList)
Beispiel #2
0
    def notifyMatchStart(self, players, group):
        try:
            ftlog.info('notifyMatchStart->user length=', len(players))
            mstart = MsgPack()
            mstart.setCmd('m_start')
            mstart.setResult('gameId', group.match.gameId)
            mstart.setResult('roomId', self._room.bigRoomId)

            userIds = [p.userId for p in players]
            ftlog.info('notifyMatchStart->begin send tcp m_start')
            router.sendToUsers(mstart, userIds)
            ftlog.info('notifyMatchStart->begin end tcp m_start')

            ftlog.info('notifyMatchStart->start bi report')
            sequence = int(group._stage.instId.split('.')[1])
            datas = {
                'userIds': userIds,
                'roomId': group.match.roomId,
                'sequence': sequence,
                'index': 0
            }
            timer.FTTimer(2, self.notifyMatchStartDelayReport_, datas)
            ftlog.info('notifyMatchStart->start bi report async !')
        except:
            ftlog.error()
Beispiel #3
0
def send_msg_only(msg, targets, seat_id):
    '''
    targets中仅仅向seat_id玩家发送消息
    @param targets 玩家players对象
    @param seat_id 发送消息的玩家的座位号
    '''
    router.sendToUsers(msg, [targets[seat_id].userId])
Beispiel #4
0
def sendMessage(gameId, targetUserIds, cmd, result, printLog=False):
    if isinstance(targetUserIds, int):
        targetUserIds = [targetUserIds]
    msg = updateMsg(cmd=cmd, result=result)
    msg.setResult('gameId', gameId)
    if printLog:
        ftlog.info('|to targetUserIds:', targetUserIds, '|msg:', msg)
    router.sendToUsers(msg, targetUserIds)
Beispiel #5
0
def sendMessage(gameId, targetUserIds, cmd, result, printLog=False):
    if isinstance(targetUserIds, int):
        targetUserIds = [targetUserIds]
    msg = updateMsg(cmd=cmd, result=result)
    msg.setResult('gameId', gameId)
    if printLog:
        ftlog.info('|to targetUserIds:', targetUserIds, '|msg:', msg)
    router.sendToUsers(msg, targetUserIds)
Beispiel #6
0
 def sendMessage(cls, gameId, targetUserIds, cmd, result, logInfo=True):
     if isinstance(targetUserIds, int):
         targetUserIds = [targetUserIds]
     msg = cls.updateMsg(cmd=cmd, result=result)
     msg.setResult('gameId', gameId)
     if logInfo:
         if _DEBUG:
             debug('|to targetUserIds:', targetUserIds, '|msg:', msg, caller=cls)
     else:
         ftlog.debug('|to targetUserIds:', targetUserIds, '|msg:', msg, caller=cls)
     router.sendToUsers(msg, targetUserIds)
Beispiel #7
0
def send_msg_except(msg, targets, seat_id=-1):
    '''
    向其他玩家广播"当前玩家"的消息
    @param targets 玩家players对象
    @param seat_id 当前玩家的座位号
    '''
    others = []
    for i in range(0, len(targets)):
        if i != seat_id and targets[i]:
            others.append(targets[i].userId)
    router.sendToUsers(msg, others)
Beispiel #8
0
 def sendMessage(cls, gameId, targetUserIds, cmd, result, logInfo=True):
     """发送消息"""
     if isinstance(targetUserIds, int):
         targetUserIds = [targetUserIds]
     msg = cls.updateMsg(cmd=cmd, result=result)
     msg.setResult('gameId', gameId)
     if logInfo:
         debug('|to targetUserIds:',
               targetUserIds,
               '|msg:',
               msg,
               caller=cls)
     else:
         ftlog.debug('|to targetUserIds:',
                     targetUserIds,
                     '|msg:',
                     msg,
                     caller=cls)
     router.sendToUsers(msg, targetUserIds)
Beispiel #9
0
    def notifyMatchStart(self, instId, signers):
        '''
        通知用户比赛开始
        '''
        try:
            self._logger.info('PlayerNotifierDizhu.notifyMatchStart',
                              'instId=', instId, 'userCount=', len(signers))
            mstart = MsgPack()
            mstart.setCmd('m_start')
            mstart.setResult('gameId', self._room.gameId)
            mstart.setResult('roomId', self._room.bigRoomId)

            userIds = [p.userId for p in signers]
            self._logger.info(
                'PlayerNotifierDizhu.notifyMatchStart begin send tcp m_start'
                'instId=', instId, 'userCount=', len(signers))
            if userIds:
                router.sendToUsers(mstart, userIds)
                self._logger.info(
                    'PlayerNotifierDizhu.notifyMatchStart end send tcp m_start'
                    'instId=', instId, 'userCount=', len(signers))

                self._logger.info(
                    'PlayerNotifierDizhu.notifyMatchStart begin send bi report'
                    'instId=', instId, 'userCount=', len(signers))
                sequence = int(instId.split('.')[1])
                datas = {
                    'userIds': userIds,
                    'roomId': self._room.roomId,
                    'sequence': sequence,
                    'index': 0
                }
                FTTimer(2, self.notifyMatchStartDelayReport_, datas)
                self._logger.info(
                    'PlayerNotifierDizhu.notifyMatchStart begin send bi report async'
                    'instId=', instId, 'userCount=', len(signers))
        except:
            self._logger.error(
                'PlayerNotifierDizhu.notifyMatchStart'
                'instId=', instId, 'userCount=', len(signers))
Beispiel #10
0
    def __sendFinalTableInfo(self, finalTableStartTime):
        waitingUserIds = self.scheduler.users.keys()  # 防止处理过程中users变化导致数据不一致
        waitingUserN = len(waitingUserIds)
        if ftlog.is_debug():
            ftlog.debug("<< |roomId:", self.roomId,
                        "|waitingUserN:", waitingUserN)

        mpToClient = MsgPack()
        mpToClient.setCmd("final_table_info")
        mpToClient.setResult('gameId', self.gameId)
        mpToClient.setResult('roomId', self.bigRoomId)
        mpToClient.setResult('finalTableStartTime', time.mktime(finalTableStartTime.timetuple()))
        mpToClient.setResult('nowServerTime', int(time.time()))

        playerInfos = []
        for seatId, userId in enumerate(waitingUserIds):
            name = userdata.getAttr(userId, 'name')

            playerRoomInfo = PlayerRoomDao.getPlayerRoomRecord(userId, self.bigRoomId)
            if ftlog.is_debug():
                ftlog.debug("get playerRoomInfo |userId, tableId:", userId, self.roomId, playerRoomInfo, caller=self)

            item = {}
            item["userId"] = userId
            item["seatId"] = seatId
            item["tableChip"] = playerRoomInfo["tableChips"]
            item["name"] = name
            playerInfos.append(item)
        mpToClient.setResult("players", playerInfos)
        router.sendToUsers(mpToClient, waitingUserIds)

        self.matchPlugin.refreshBuyin(self)

        # Send final table information to monitor_mtt.py
        TYPluginCenter.event(TYPluginUtils.updateMsg(cmd='EV_MTT_FINAL_TABLE', params={
            'roomId': self.roomId}), self.gameId)