private RequestHandlingResult GetServerInformation(string request) { var splitedRequest = ServerInfoRegex.Split(request); if (splitedRequest[1] == "info") { var serializeServers = jsonSerializer.Serialize(AdvertiseServers.Values.ToArray()); return(RequestHandlingResult.Successfull(serializeServers.GetBytesInAscii())); } var endpoint = splitedRequest[1]; var neededGames = GameServers.Where(x => x.Endpoint == endpoint).ToArray(); var neededAdvertServer = AdvertiseServers.Where(x => x.Key == endpoint).ToArray(); if (!neededAdvertServer.Any() && neededGames.Length == 0) { return(RequestHandlingResult.Fail(HttpStatusCode.NotFound)); } object informations; switch (splitedRequest[2]) { case "info": informations = neededAdvertServer[0].Value.Info; break; case "matches": return(GetAdvertMatch(splitedRequest[3], neededGames)); case "stats": informations = statistic.GetServerStatistic(neededGames); break; default: return(RequestHandlingResult.Fail(HttpStatusCode.BadRequest)); } var serializeInformation = jsonSerializer.Serialize(informations); return(RequestHandlingResult.Successfull(serializeInformation.GetBytesInAscii())); }
private bool CheckGameMode(string endpoint, string gameMode) { return(AdvertiseServers.Where(x => x.Key == endpoint) .Select(x => x.Value.Info.GameModes).Any(x => x.Contains(gameMode))); }