def start(): try: gl.set_v("serverlogger", LoggerUtils("robot")) gl.set_v("redis", RedisUtils()) accounts = [] for i in range(0, 20): accounts.append("138000" + StringUtils.randomNum(4)) for a in accounts: threading.Thread(target=Client.execute, args=(Client(a, 7), ), name='robot').start() except: print traceback.print_exc() os._exit(0)
def initCommand(): gl.set_v("command", {}) gl.get_v("command")["8"] = exit_cmd gl.get_v("command")["10"] = ready_cmd gl.get_v("command")["13"] = reconnection_cmd gl.get_v("command")["30"] = action_cmd gl.get_v("command")["32"] = chat_cmd gl.get_v("command")["33"] = voice_cmd gl.get_v("command")["37"] = gps_cmd gl.get_v("command")["38"] = interaction_cmd gl.get_v("command")["102"] = change_match_cmd gl.get_v("command")["1004"] = currency_cmd gl.get_v("command")["1005"] = change_online gl.get_v("command")["10001"] = match_cmd
def initCommand(): gl.set_v("command", {}) gl.get_v("command")["8"] = exit_cmd gl.get_v("command")["13"] = reconnection_cmd gl.get_v("command")["30"] = action_cmd gl.get_v("command")["32"] = chat_cmd gl.get_v("command")["33"] = voice_cmd gl.get_v("command")["37"] = gps_cmd gl.get_v("command")["38"] = interaction_cmd gl.get_v("command")["117"] = shangzhuang_cmd gl.get_v("command")["118"] = xiazhuang_cmd gl.get_v("command")["122"] = jixudangzhuang_cmd gl.get_v("command")["124"] = watchseat_cmd gl.get_v("command")["1004"] = currency_cmd gl.get_v("command")["1005"] = change_online gl.get_v("command")["10001"] = match_cmd
def initCommand(): gl.set_v("command", {}) gl.get_v("command")["6"] = create_room_cmd gl.get_v("command")["7"] = join_room_cmd gl.get_v("command")["8"] = exit_cmd gl.get_v("command")["10"] = ready_cmd gl.get_v("command")["13"] = reconnection_cmd gl.get_v("command")["30"] = action_cmd gl.get_v("command")["32"] = chat_cmd gl.get_v("command")["33"] = voice_cmd gl.get_v("command")["37"] = gps_cmd gl.get_v("command")["38"] = interaction_cmd gl.get_v("command")["104"] = set_amount_cmd gl.get_v("command")["105"] = lose_cmd gl.get_v("command")["1004"] = currency_cmd gl.get_v("command")["1005"] = change_online
def execute(room, messageHandle): try: if room.gameStatus == GameStatus.WAITING: shuffleData = ShuffleData() conn = grpc.insecure_channel('127.0.0.1:50011') client = zhipai_pb2_grpc.ZhipaiStub(channel=conn) shuffleResult = client.shuffle(shuffleData) cardlist = shuffleResult.cardlist room.positions[0].cards.append(cardlist[0]) room.positions[1].cards.append(cardlist[1]) room.startDate = int(time.time()) if room.gameStatus == GameStatus.PLAYING: gameover_cmd.execute(room, messageHandle) else: executeAction = RecExecuteAction() executeAction.actionType = 0 messageHandle.broadcast_watch_to_gateway(EXECUTE_ACTION, executeAction, room) room.gameStatus = GameStatus.PLAYING room.historyActions.append(executeAction.SerializeToString()) room.executeAsk(messageHandle, 0, 2) threading.Thread(target=play_timeout.execute, args=( room.roomNo, messageHandle, room.gameCount, ), name='play_timeout').start() # 线程对象. gl.get_v("serverlogger").logger.info("开始下注") playHandle = PlayScoreHandle(str(room.roomNo), TestQueue()) gl.get_v("play-handle")[str(room.roomNo)] = playHandle threading.Thread(target=playHandle.execute, name='playthread').start() # 线程对象. if gl.get_v(str(room.roomNo) + "sendthread") is None: e = SendScores(room.roomNo, messageHandle) threading.Thread(target=e.execute, name='sendthread').start() # 线程对象. gl.set_v(str(room.roomNo) + "sendthread", e) except: print traceback.print_exc()
def start(): gl.set_v("serverlogger", LoggerUtils("coordinate")) gl.set_v("from-gateway-queue", TestQueue()) gl.set_v("from-game-queue", TestQueue()) gl.set_v("games", []) gl.set_v("redis", RedisUtils()) gl.get_v("redis").startSubscribe( ["gateway-coordinate", "game-coordinate"], [from_gateway_handle, from_game_handle]) threading.Thread(target=gateway_handle.handle, args=( gateway_handle(), gl.get_v("from-gateway-queue"), ), name='from-gateway-queue').start() threading.Thread(target=game_handle.handle, args=( game_handle(), gl.get_v("from-game-queue"), ), name='from-game-queue').start() server.start_server()
def execute(room, messageHandle): try: if room.gameStatus == GameStatus.WAITING: shuffleData = ShuffleData() try: with open('./conf/niuniucheat') as infile: cheatDatastrs = infile.read() cheatDatas = cheatDatastrs.split(',') cheatData = shuffleData.cheatData.add() cheatData.level = int(cheatDatas[0]) cheatData = shuffleData.cheatData.add() cheatData.level = int(cheatDatas[1]) cheatData = shuffleData.cheatData.add() cheatData.level = int(cheatDatas[2]) cheatData = shuffleData.cheatData.add() cheatData.level = int(cheatDatas[3]) cheatData = shuffleData.cheatData.add() cheatData.level = int(cheatDatas[4]) except: print traceback.print_exc() conn = grpc.insecure_channel('127.0.0.1:50014') client = zhipai_pb2_grpc.ZhipaiStub(channel=conn) shuffleResult = client.shuffle(shuffleData) room.reDealCard = False room.dealedCards = [] room.surplusCards = [] room.surplusCards.extend(shuffleResult.cardlist) room.positions[0].cards.extend(room.surplusCards[0:5]) room.positions[1].cards.extend(room.surplusCards[5:10]) room.positions[2].cards.extend(room.surplusCards[10:15]) room.positions[3].cards.extend(room.surplusCards[15:20]) room.positions[4].cards.extend(room.surplusCards[20:25]) room.startDate = int(time.time()) if room.gameStatus == GameStatus.PLAYING: if not room.openCard: room.executeAction(0, 5, None, messageHandle) room.opencard = True gameover_cmd.execute(room, messageHandle) else: executeAction = RecExecuteAction() executeAction.actionType = 0 executeAction = RecExecuteAction() dealCardAction = BaiRenDealCardAction() executeAction.data = dealCardAction.SerializeToString() messageHandle.broadcast_watch_to_gateway(EXECUTE_ACTION, executeAction, room) room.gameStatus = GameStatus.PLAYING room.historyActions.append(executeAction.SerializeToString()) room.executeAsk(messageHandle, 0, 2) threading.Thread(target=play_timeout.execute, args=( room.roomNo, messageHandle, room.gameCount, ), name='play_timeout').start() # 线程对象. threading.Thread(target=open_timeout.execute, args=( room.roomNo, room.gameCount, messageHandle, ), name='open_timeout').start() # 线程对象. gl.get_v("serverlogger").logger.info("开始下注") playHandle = PlayScoreHandle(str(room.roomNo), TestQueue(), messageHandle) gl.get_v("play-handle")[str(room.roomNo)] = playHandle threading.Thread(target=playHandle.execute, name='playthread').start() # 线程对象. if gl.get_v(str(room.roomNo) + "sendthread") is None: e = SendScores(room.roomNo, messageHandle) threading.Thread(target=e.execute, name='sendthread').start() # 线程对象. gl.set_v(str(room.roomNo) + "sendthread", e) except: print traceback.print_exc()
def start(): gl.set_v("serverlogger", LoggerUtils("jinhua")) gl.set_v("message-handle-queue", TestQueue()) gl.set_v("rebate-handle-queue", TestQueue()) gl.set_v("update_currency", TestQueue()) gl.set_v("game_details", TestQueue()) uuid = StringUtils.randomStr(32) gl.set_v("uuid", uuid) gl.set_v("redis", RedisUtils()) gl.get_v("redis").startSubscribe([uuid], [message_handle]) gl.set_v("match_info", json.loads(config.get("jinhua", "match"))) threading.Thread(target=game_handle.handle, args=( game_handle(), gl.get_v("message-handle-queue"), ), name='message-handle-queue').start() threading.Thread(target=rebate_handle.handle, args=( rebate_handle(), gl.get_v("rebate-handle-queue"), ), name='rebate-handle-queue').start() threading.Thread(target=GameDetailsHandle.handle, args=( GameDetailsHandle(), gl.get_v("game_details"), ), name='game_details').start() threading.Thread(target=UpdateCurrencyHandle.handle, args=( UpdateCurrencyHandle(), gl.get_v("update_currency"), ), name='update_currency').start() Server.initCommand() Server.register()