Esempio n. 1
0
        // 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()));
            }
        }
Esempio n. 2
0
        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()));
            }
        }
Esempio n. 3
0
            internal async Task Load(Action <IList <ServerQueryResult> > onNext, IObservable <IPEndPoint> masterObservable)
            {
                var rs = new ReactiveSource();

                using (var udpClient = CreateUdpClient()) {
                    var directObs = rs.GetResults(
                        masterObservable,
                        udpClient, new QuerySettings {
                        DegreeOfParallelism = 40,
                        InclRules           = true
                    });
                    await
                    rs.ProcessResults(directObs.ObserveOn(TaskPoolScheduler.Default)).Buffer(231)
                    .Do(onNext);
                }
            }
 // 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());
     }
 }
 internal async Task Load(Action<IList<ServerQueryResult>> onNext, IObservable<IPEndPoint> masterObservable) {
     var rs = new ReactiveSource();
     using (var udpClient = CreateUdpClient()) {
         var directObs = rs.GetResults(
                 masterObservable,
                 udpClient, new QuerySettings {
                     DegreeOfParallelism = 40,
                     InclRules = true
                 });
         await
             rs.ProcessResults(directObs.ObserveOn(TaskPoolScheduler.Default)).Buffer(231)
                 .Do(onNext);
     }
 }
        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());
            }
        }