public ServerQueryResult ParsePackets(ServerQueryState state) {
     if (state.ReceivedPackets.Count != 3)
         throw new Exception("Wrong number of packets");
     return ParseResponse(state.ReceivedPackets[0], state.ReceivedPackets[1], state.ReceivedPackets[2],
         Convert.ToInt64(state.Pings.Average()),
         state.Server);
 }
        public Task UpdateAsync(ServerQueryState state) {
            state.MaxPackets = 3;
            state.Client = Connect(state.EndPoint);
            _state = state;

            return FetchAsync();
        }
 static void TryUpdateServerFromSyncInfo(ServerQueryState item) {
     try {
         item.Server.UpdateInfoFromResult(item.Result);
     } catch {
         item.Server.IsUpdating = false;
         throw;
     }
 }
 public async Task ServerInfo() {
     var mq = new SourceMasterQuery("dayz");
     var servers = await mq.GetParsedServers(false, 200).ConfigureAwait(false);
     //TODO: not all servers returned will respond, allow timeout or verify good servers?
     servers = servers.OrderBy(x => Guid.NewGuid()).Take(3);
     foreach (var d in servers) {
         var split = d.Settings["address"].Split(':');
         var sq = new SourceServerQuery(new ServerAddress(IPAddress.Parse(split[0]), Convert.ToInt32(split[1])),
             "dayz", new SourceQueryParser());
         var state = new ServerQueryState {Server = A.Fake<Server>()};
         await sq.UpdateAsync(state).ConfigureAwait(false);
         state.Exception.Should().BeNull();
         state.Success.Should().BeTrue();
     }
 }
Example #5
0
 public Task QueryServer(ServerQueryState state) {
     return serverQueryInfo.QueryServer(state);
 }
 public override Task QueryServer(ServerQueryState state) {
     return queryHandler.QueryServer(state);
 }
Example #7
0
 public override Task QueryServer(ServerQueryState state) {
     switch (Settings.ServerQueryMode) {
     case ServerQueryMode.All: {
         if (state.Server.QueryMode == ServerQueryMode.Steam)
             return sourceServersQuery.QueryServer(state);
         if (state.Server.QueryMode == ServerQueryMode.Gamespy)
             return gamespyServersQuery.QueryServer(state);
         return Task.WhenAll(sourceServersQuery.QueryServer(state), gamespyServersQuery.QueryServer(state));
     }
     case ServerQueryMode.Gamespy:
         return gamespyServersQuery.QueryServer(state);
     case ServerQueryMode.Steam:
         return sourceServersQuery.QueryServer(state);
     default:
         throw new InvalidOperationException("Unknown server query: " + Settings.ServerQueryMode);
     }
 }
Example #8
0
 public override Task QueryServer(ServerQueryState state) {
     throw new NotImplementedException();
 }
Example #9
0
 public abstract Task QueryServer(ServerQueryState state);
 public ServerQueryResult ParsePackets(ServerQueryState state) {
     return ParseResponse(JoinPackets(state.ReceivedPackets), Convert.ToInt64(state.Pings.Average()),
         state.Server);
 }
 public Task QueryServer(ServerQueryState state) {
     return new GamespyServerQuery(state.Server.Address, Tag, new GamespyQueryParser())
         .UpdateAsync(state);
 }