// todo; use factory private static async Task <BatchResult> GetFromGameServerQuery( IEnumerable <IPEndPoint> addresses, ServerQueryOptions options, Action <Server> act) { var q = new ReactiveSource(); using (var client = q.CreateUdpClient()) { return(new BatchResult(await q.ProcessResults(q.GetResults(addresses, client, new QuerySettings { InclPlayers = options.InclPlayers, InclRules = options.InclExtendedDetails })) .Do(x => { var serverInfo = new Server { QueryAddress = x.Address }; var r = (SourceParseResult)x.Settings; r.MapTo(serverInfo); serverInfo.Ping = x.Ping; var tags = r.Keywords; if (tags != null) { var p = GameTags.Parse(tags); p.MapTo(serverInfo); } act(serverInfo); }).Count())); } }
private static async Task <BatchResult> GetFromGameServerQuery( IEnumerable <IPEndPoint> addresses, ServerQueryOptions options, Action <Server> act) { var q = new ReactiveSource(); using (var client = q.CreateUdpClient()) { var results = q.ProcessResults(q.GetResults(addresses, client, new QuerySettings { InclPlayers = options.InclPlayers, InclRules = options.InclExtendedDetails })); results = options.InclPlayers ? results.Do(x => MapServerInclPlayers(act, x)) : results.Do(x => MapServer(act, x)); return(new BatchResult(await results.Count())); } }
// todo; use factory private static async Task<BatchResult> GetFromGameServerQuery( IEnumerable<IPEndPoint> addresses, ServerQueryOptions options, Action<Server> act) { var q = new ReactiveSource(); using (var client = q.CreateUdpClient()) { return new BatchResult(await q.ProcessResults(q.GetResults(addresses, client, new QuerySettings { InclPlayers = options.InclPlayers, InclRules = options.InclExtendedDetails })) .Do(x => { var serverInfo = new Server {QueryAddress = x.Address}; var r = (SourceParseResult) x.Settings; r.MapTo(serverInfo); serverInfo.Ping = x.Ping; var tags = r.Keywords; if (tags != null) { var p = GameTags.Parse(tags); p.MapTo(serverInfo); } act(serverInfo); }).Count()); } }
private static async Task<BatchResult> GetFromGameServerQuery( IEnumerable<IPEndPoint> addresses, ServerQueryOptions options, Action<Server> act) { var q = new ReactiveSource(); using (var client = q.CreateUdpClient()) { var results = q.ProcessResults(q.GetResults(addresses, client, new QuerySettings { InclPlayers = options.InclPlayers, InclRules = options.InclExtendedDetails })); results = options.InclPlayers ? results.Do(x => MapServerInclPlayers(act, x)) : results.Do(x => MapServer(act, x)); return new BatchResult(await results.Count()); } }