예제 #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()));
            }
        }
예제 #2
0
        private static async Task UpdateServerInfo(ArmaServerInfoModel s, SteamApi api, bool inclRules)
        {
            s.GameTags = s.Tags == null ? null : GameTags.Parse(s.Tags);
            if (inclRules)
            {
                var rules = await api.GetServerRules(s.QueryEndPoint).ConfigureAwait(false);

                var mods = SourceQueryParser.GetList(rules, "modNames");
                s.SignatureList = SourceQueryParser.GetList(rules, "sigNames").ToHashSet();
                s.ModList       = mods.Select(x => new ServerModInfo {
                    Name = x
                }).ToList();
            }
        }
예제 #3
0
 public ArmaServerProfile()
 {
     CreateMap <ArmaServerInfo, ArmaServerInfoModel>();
     CreateMap <ServerModInfo, GameServerQuery.Games.RV.ServerModInfo>();
     CreateMap <SourceParseResult, ArmaServerInfoModel>()
     .ConstructUsing((src) => new ArmaServerInfoModel(src.Address))
     .ForMember(x => x.ConnectionEndPoint, opt =>
                opt.MapFrom(
                    src => new IPEndPoint(src.Address.Address, src.Port > 0 ? src.Port : src.Address.Port - 1)))
     .ForMember(x => x.Mission, opt => opt.MapFrom(src => src.Game))
     //.ForMember(x => x.IsDedicated, opt => opt.MapFrom(src => src.ServerType > 0))
     .ForMember(x => x.Tags, opt => opt.MapFrom(src => src.Keywords))
     .ForMember(x => x.RequirePassword, opt => opt.MapFrom(src => src.Visibility > 0))
     .ForMember(x => x.IsVacEnabled, opt => opt.MapFrom(src => src.Vac > 0))
     .ForMember(x => x.GameTags,
                opt => opt.MapFrom(src => src.Keywords == null ? null : GameTags.Parse(src.Keywords)));
 }
예제 #4
0
 public AMProfile()
 {
     CreateMap <SourceParseResult, Server>()
     .Include <SourceParseResult, ArmaServer>()
     .Include <SourceParseResult, ArmaServerWithPlayers>()
     .SourceParseResultToServer();
     CreateMap <SourceParseResult, ArmaServer>()
     .Include <SourceParseResult, ArmaServerWithPlayers>()
     .SourceParseResultToServer()
     .AfterMap((src, dest) => {
         var tags = src.Keywords;
         if (tags != null)
         {
             var p = GameTags.Parse(tags);
             p.MapTo(dest);
         }
     });
     CreateMap <SourceParseResult, ArmaServerWithPlayers>();
 }
예제 #5
0
 public static ArmaServerInfo FromWrap(int serverIndex, GameServerItemWrap serverData)
 {
     try {
         return(new ArmaServerInfo(serverIndex, new ServerKey(serverData.IP, serverData.QueryPort))
         {
             ConnectionEndPoint = new ServerKey(serverData.IP, serverData.ConnectionPort).ToIpEndpoint(),
             Name = serverData.Name,
             Map = serverData.Map,
             Mission = serverData.Description,
             ServerVersion = serverData.ServerVersion,
             RequirePassword = serverData.RequirePassword,
             IsVacEnabled = serverData.IsVACSecure,
             CurrentPlayers = serverData.Players,
             MaxPlayers = serverData.MaxPlayers,
             Ping = serverData.Ping,
             Tags = serverData.Tags,
             GameTags = GameTags.Parse(serverData.Tags)
         });
     } catch {
         return(new ArmaServerInfo(serverIndex, new ServerKey(serverData.IP, serverData.QueryPort)));
     }
 }