public async Task <ActionResult> connectPlayer(int gameId) { Game game = games.First(game => game.Id == gameId); int index = games.IndexOf(game); game.PlayerConnectionId = UserHandler.dictionary.Where(con => con.Value == gameId).Skip(1).First().Key; // UserHandler.dictionary.Remove(game.PlayerConnectionId); game.CountOfPlayers++; games[index] = game; MessageResponce messageResponce = new MessageResponce(); messageResponce.Message = "client connected to game " + UserHandler.dictionary.Count; return(Ok(game)); }
public async Task <ActionResult> getAll() { if (games.Count != 0) { List <GameResponce> responces = new List <GameResponce>(); List <Game> notFinished = games.FindAll(game => !game.finished); notFinished.ForEach(game => responces.Add(new GameResponce(game.Id, game.Name, game.CountOfPlayers, game.Tags))); return(Ok(responces)); } else { MessageResponce messageResponce = new MessageResponce(); messageResponce.Message = "No data"; return(BadRequest(messageResponce)); } }
public async Task <ActionResult> CreateCreator(GameRequest gameRequest) { // Устанавливаем для сокета локальную конечную точку Game game = new Game(); game.Id = gameRequest.Id; game.Name = gameRequest.Name; game.CountOfPlayers++; game.Tags = gameRequest.GameTags; game.finished = false; game.CreatorConnectionId = UserHandler.dictionary.FirstOrDefault(con => con.Value == gameRequest.Id).Key; // UserHandler.dictionary.Remove(game.CreatorConnectionId); games.Add(game); MessageResponce messageResponce = new MessageResponce(); messageResponce.Message = "game was created " + UserHandler.dictionary.Count; return(Ok(game)); }
static void Main(string[] args) { Console.Title = typeof(Program).Namespace; while (true) { string input = RabbitMq.RabbitMq.Output("PBAG3_BankRabbit"); MessageRequest messageRequest = JsonConvert.DeserializeObject <MessageRequest>(input); double intrest_rate = 2 + new Random().Next(10) + new Random().NextDouble(); MessageResponce messageResponce = new MessageResponce { ssn = messageRequest.ssn, interestRate = intrest_rate }; string jsonObject = JsonConvert.SerializeObject(messageResponce); bool success = RabbitMq.RabbitMq.Input("PBAG3_Normalizer", jsonObject); } }