// todo rewrite HandleCreateGameMessage and HandleJoinGameMessage. They are almost the same private static List <Message> HandleCreateGameMessage(Message message, string userId) { var result = new List <Message>(); var createGameMessage = message as CreateGameMessage; Player player = (Player)AbstractPlayers.FirstOrDefault(p => p.Id == userId); if (player == null) { Logger.Write($"Cannot find player with id {userId} in connected players", LogLevel.Error); } else { var game = GameManager.CreateGame(createGameMessage.GameType, player); createGameMessage.GameId = game.GameId; createGameMessage.IsBroadcast = false; result.Add(createGameMessage); } return(result); }