Inheritance: IMasterServerQuery
Exemple #1
0
 public static IObservable <ServerPageArgs> BuildObservable(this SourceMasterQuery master)
 => Observable.FromEvent <EventHandler <ServerPageArgs>, ServerPageArgs>(handler => {
     EventHandler <ServerPageArgs> evtHandler = (sender, e) => handler(e);
     return(evtHandler);
 },
                                                                         evtHandler => master.ServerPageReceived += evtHandler,
                                                                         evtHandler => master.ServerPageReceived -= evtHandler);
 public async Task<BatchResult> GetServers(IServerQueryFactory factory, CancellationToken cancelToken,
     Action<List<IPEndPoint>> act) {
     var master = new SourceMasterQuery(ServerFilterBuilder.Build().FilterByGame("starbound").Value);
     return new BatchResult(await master.GetParsedServersObservable(cancelToken)
         .Do(x => act(x.Items))
         .SelectMany(x => x.Items)
         .Count());
 }
 public async Task<BatchResult> GetServerAddresses(uint appId, Action<List<IPEndPoint>> act,
     CancellationToken cancelToken) {
     var f = ServerFilterBuilder.Build()
         .FilterByGame("arma3");
     var master = new SourceMasterQuery(f.Value);
     return new BatchResult(await master.GetParsedServersObservable(cancelToken)
         .Do(x => act(x.Items))
         .SelectMany(x => x.Items)
         .Count());
 }
Exemple #4
0
 public static IObservable <ServerPageArgs> GetParsedServersObservable(this SourceMasterQuery This,
                                                                       CancellationToken cancelToken,
                                                                       bool forceLocal = false, int limit = 0) => Observable.Create <ServerPageArgs>(async obs => {
     try {
         using (This.BuildObservable().Subscribe(obs.OnNext)) {
             await This.GetParsedServers(cancelToken, limit).ConfigureAwait(false);
         }
     } catch (Exception ex) {
         obs.OnError(ex);
         return;
     }
     obs.OnCompleted();
 });
 public async Task Test() {
     var q =
         new SourceMasterQuery(ServerFilterBuilder.Build().FilterByGame("arma3").FilterByDedicated().Value);
     var servers = await q.GetParsedServers(CancellationToken.None).ConfigureAwait(false);
     Console.WriteLine(string.Join(",", servers));
 }