def updateUtilMatchStatus(match_count, userId): if util_match_map.has_key(match_count): util_match_map[match_count][userId] = 1 start = 1 userId_b = 0 for uid, status in util_match_map[match_count].items(): if _DEBUG: debug("IN updateUtilMatchStatus @@@ in LOOP: userId = ", userId, " status = ", status) if status == 0: start = 0 break if uid != userId: userId_b = uid if _DEBUG: debug("IN updateUtilMatchStatus @@@ userId_b = ", userId_b) if start == 1: #随机取出roomId roomid_key = choice(tyglobal.bigRoomIdsMap().keys()) roomid = choice(tyglobal.bigRoomIdsMap()[roomid_key]) #随机取出shadowRoomId allrooms = tyglobal.roomIdDefineMap() shadowRoomId = choice(allrooms[roomid].shadowRoomIds) if _DEBUG: debug("IN updateUtilMatchStatus @@@ roomid = ", roomid, " shadowRoomId = ", shadowRoomId, "userId_a =", userId, "userId_b =", userId_b) gameRpcRoomOne.srvtable.doCreateNewTable(shadowRoomId, userId, userId_b)
def _doJoinCreateTable(self, room, msg): ''' 加入牌桌 ''' assert room.roomId == msg.getParam("roomId") userId = msg.getParam("userId") gameId = msg.getParam("gameId") shadowRoomId = msg.getParam("shadowRoomId") tableId = msg.getParam("tableId") clientId = msg.getParam("clientId") tableIdNo = msg.getParam("createTableNo") playMode = room.roomConf.get("playMode") initParams = CreateTableData.getTableParamsByCreateTableNo(tableIdNo) ftlog.debug('RoomTcpHandler._doJoinCreateTable tableNo:', tableIdNo, ' initParams:', initParams) fangKaCount = self.getFangKaCountByTableNo(tableIdNo, initParams, userId, gameId, playMode) ftlog.info( "RoomTcpHandler._doJoinCreateTable >>> userId, clientId, roomId, shadowRoomId, tableId, fangKaCount:", userId, clientId, room.roomId, shadowRoomId, tableId, fangKaCount) if (fangKaCount > 0) and (not self.consumeFangKa( room, userId, gameId, initParams, playMode, fangKaCount)): return assert isinstance(shadowRoomId, int) and tyglobal.roomIdDefineMap( )[shadowRoomId].bigRoomId == room.roomDefine.bigRoomId extParams = msg.getKey('params') room.querySitReq(userId, shadowRoomId, tableId, clientId, extParams)
def doAwardCertificate(userId, gameId, match_id, clientId, msg): ''' TCP 发送的至UTIL服务的quick_start暂时不能用lock userid的方式, 因为,消息流 CO->UT->GR->GT->UT会死锁 ''' roomId = msg.getParam("roomId") ftlog.debug('doAwardCertificate', userId, gameId, roomId, match_id) if len(str(roomId)) != 4 and len(str(roomId)) != 8 and len( str(roomId)) != 0: roomIdx = roomId roomId = roomId * 100 ftlog.info("doAwardCertificate roomID error, from %d change to %d" % (roomIdx, roomId)) allrooms = tyglobal.roomIdDefineMap() ctrlRoomId = roomId if roomId in allrooms: roomDef = allrooms[roomId] if roomDef.parentId > 0: # this roomId is shadowRoomId ctrlRoomId = roomDef.parentId else: ftlog.warn("doAwardCertificate, error roomId", roomId) return ftlog.debug("ctrlRoomId:", ctrlRoomId) msg1 = MsgPack() msg1.setCmd('room') msg1.setParam('gameId', gameId) msg1.setParam('userId', userId) msg1.setParam('roomId', ctrlRoomId) msg1.setParam('action', "match_award_certificate") msg1.setParam('match_id', match_id) msg1.setParam('clientId', clientId) router.sendRoomServer(msg1, roomId)