Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions GamesDat.Demo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,11 @@ static async Task CaptureWarThunderSession()

lastValidData = data.Valid;

if (data.Valid)
if (data.Valid && frameCount % 1 == 0) // Update every frame (10Hz)
{
// Clear and redraw dashboard every frame
if (frameCount % 1 == 0) // Update every frame (10Hz)
{
Console.SetCursorPosition(0, 4);
DrawDashboard(data);
}
Console.SetCursorPosition(0, 4);
DrawDashboard(data);
}
});

Expand Down
2 changes: 1 addition & 1 deletion GamesDat/Telemetry/Sources/HttpPollingSourceBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public override async IAsyncEnumerable<T> ReadContinuousAsync(
yield return data;
await Task.Delay(_options.PollInterval, cancellationToken);
}
else if (!hasData)
else
{
// Wait before retry (for connection errors or JSON errors)
var delayTime = _consecutiveErrors > 0 ? _currentRetryDelay : _options.PollInterval;
Expand Down
2 changes: 1 addition & 1 deletion GamesDat/Telemetry/Sources/WarThunder/StateData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace GamesDat.Core.Telemetry.Sources.WarThunder;
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
[GameId("WarThunder")]
[DataVersion(1, 0, 0)]
[DataVersion(2, 0, 0)]
public struct StateData
{
// Validity
Expand Down
19 changes: 4 additions & 15 deletions GamesDat/Telemetry/Sources/WarThunder/StateSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ namespace GamesDat.Core.Telemetry.Sources.WarThunder;
public class StateSource : HttpPollingSourceBase<StateData>
{
private readonly StateSourceOptions _stateOptions;
private DateTime _lastInvalidFrameLog = DateTime.MinValue;

/// <summary>
/// Initializes a new instance with StateSourceOptions.
Expand All @@ -31,8 +30,7 @@ public StateSource(StateSourceOptions options)
public StateSource(HttpPollingSourceOptions options)
: this(new StateSourceOptions
{
HttpOptions = options,
SkipInvalidFrames = true
HttpOptions = options
})
{
}
Expand All @@ -50,29 +48,20 @@ public StateSource(string baseUrl, TimeSpan pollInterval)
BaseUrl = baseUrl,
EndpointPath = "/state",
PollInterval = pollInterval
},
SkipInvalidFrames = true
}
})
{
}

/// <summary>
/// Continuously polls the HTTP endpoint and yields valid telemetry data.
/// Filters out invalid frames if SkipInvalidFrames is enabled.
/// Continuously polls the HTTP endpoint and yields telemetry data.
/// </summary>
public override async IAsyncEnumerable<StateData> ReadContinuousAsync(
[EnumeratorCancellation] CancellationToken cancellationToken)
{
await foreach (var data in base.ReadContinuousAsync(cancellationToken))
{
// If not filtering invalid frames, yield everything
if (!_stateOptions.SkipInvalidFrames)
{
yield return data;
continue;
}

yield return data;
yield return data;
}
}
}
13 changes: 0 additions & 13 deletions GamesDat/Telemetry/Sources/WarThunder/StateSourceOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,4 @@ public class StateSourceOptions
/// HTTP polling options (URL, intervals, retry settings).
/// </summary>
public required HttpPollingSourceOptions HttpOptions { get; init; }

/// <summary>
/// If true, frames where Valid=false will be skipped (not yielded).
/// When enabled, the source will continue polling but only yield valid frames.
/// Default is true (skip invalid frames).
/// </summary>
public bool SkipInvalidFrames { get; init; } = true;

/// <summary>
/// Interval for logging "waiting for valid data" messages when skipping invalid frames.
/// Set to TimeSpan.Zero to disable these messages. Default is 10 seconds.
/// </summary>
public TimeSpan InvalidFrameLogInterval { get; init; } = TimeSpan.FromSeconds(10);
}