protected List <Route> BuildRoutes(string clientVersion, EntityDictionary <ServerInfo> serverInfoList) { var result = new List <Route>(); if (serverInfoList == null || !serverInfoList.Any()) { return(result); } var servers = serverInfoList.Where(s => s.ClientVersionList.Contains(clientVersion) && s.IsApproved).ToList(); var regions = servers.Select(s => s.Region).Distinct(); foreach (var region in regions) { //ping host is game server in this region var pingHost = servers.FirstOrDefault(s => s.ServerRole == ServerRole.GameServer && s.Region == region); //get matchmaker var matchMaker = servers.FirstOrDefault(s => s.ServerRole == ServerRole.MatchMaker && s.Region == region); //get backend var backEnd = servers.FirstOrDefault(s => s.ServerRole == ServerRole.BackEnd && s.Region == region); if (pingHost != null && matchMaker != null && backEnd != null) { var protocol = backEnd.HttpsPort > 0 ? "https" : "http"; var port = backEnd.HttpsPort > 0 ? backEnd.HttpsPort : backEnd.HttpPort; result.Add(new Route(region, matchMaker.Name, pingHost.Address, protocol, backEnd.Address, port, backEnd.Id, matchMaker.Address, matchMaker.GetLessLoadedPort())); } } return(result); }