public void Enqueue(Kv kv) { int gameID = kv.GetInt32("GameID"); if (consumers.ContainsKey(gameID)) { if (gameID > 0 && consumers[gameID].Game != null) { MethodNameE mn = (MethodNameE)kv.GetInt32("MethodName"); if (consumers[gameID].Game.Flags.IsNotReady && mn != MethodNameE.RestartGame && mn != MethodNameE.RestartGameWithSetup && mn != MethodNameE.WriteChatMessage && mn != MethodNameE.ForceLogoff) { return; } } consumers[gameID].ConsumeMessage(kv); } else { if (!queues.ContainsKey(gameID)) { queues.Add(gameID, new Queue <Kv>()); } queues[gameID].Enqueue(kv); } }
void DoConsumeMessage(Kv kv) { MethodNameE MethodName = (MethodNameE)kv.GetInt32("MethodName"); #region Switch MethodName switch (MethodName) { case MethodNameE.BannedUser: BanUser(kv); break; case MethodNameE.KickedUser: KickUser(); break; case MethodNameE.BlockIP: BlockIP(); break; case MethodNameE.WriteChatMessage: WriteChatMessage(kv); break; case MethodNameE.SystemInformation: SystemInformation(kv); break; case MethodNameE.UpdateGameDataByGameID: case MethodNameE.Abort: Abort(kv); break; case MethodNameE.AvChat: AvChat(kv); break; case MethodNameE.ForceLogoff: CloseAllWindows(); break; case MethodNameE.BlockMachine: BlockMachine(kv); break; case MethodNameE.StartTournamentMatch: StartTournamentMatch(kv); break; case MethodNameE.PingClient: PingClient(); break; case MethodNameE.GetDataByRoomID: GetDataByRoomID(kv); break; } #endregion }
void DoConsumeMessage(Kv kv) { MethodNameE MethodName = (MethodNameE)kv.GetInt32("MethodName"); switch (MethodName) { case MethodNameE.UpdateGameDataByGameID: SetGamePrameters(kv); break; case MethodNameE.Resign: UserResign(kv); break; case MethodNameE.Abort: UserAbort(); break; case MethodNameE.Draw: UserDraw(kv); break; case MethodNameE.NewGame: UserNewGame(kv); break; case MethodNameE.TimeExpired: TimeIsExpired(kv); break; case MethodNameE.KingStaleMated: UserKingStaleMated(); break; case MethodNameE.ThreefoldRepetition: UserThreefoldRepetition(kv); break; case MethodNameE.AddAudienceAsync: this.AddAudience(kv); break; case MethodNameE.RemoveAudience: this.RemoveAudience(kv); break; case MethodNameE.BanUser: BanUser(kv); break; case MethodNameE.KickUser: KickUser(); break; case MethodNameE.BlockIP: BlockIP(); break; case MethodNameE.WriteChatMessage: WriteChatMessage(kv); break; case MethodNameE.ForceLogoff: CloseAllWindows(); break; case MethodNameE.SetGamePositionByFen: SetGamePositionByFen(kv); break; case MethodNameE.CloseInProgressGameWindow: CloseInProgressGameWindow(kv); break; case MethodNameE.RestartGame: RestartGame(kv); break; case MethodNameE.RestartGameWithSetup: RestartGameWithSetup(kv); break; case MethodNameE.RescheduleTournament: SetRescheduleTournament(); break; case MethodNameE.ForcedGameWin: ForcedGameWin(kv); break; } }