Skip to content

Commit dec7dc7

Browse files
authored
Add hz parameter validation to WarThunder factory methods (#16)
1 parent f3030d9 commit dec7dc7

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

GamesDat/Telemetry/Sources/WarThunder/WarThunderSources.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ public static class WarThunderSources
1717
/// <returns>A configured StateSource instance.</returns>
1818
public static StateSource CreateStateSource(string? baseUrl = null, int hz = 60)
1919
{
20+
if (hz <= 0)
21+
throw new ArgumentOutOfRangeException(nameof(hz), hz, "Polling frequency must be greater than 0");
22+
2023
var pollInterval = TimeSpan.FromMilliseconds(1000.0 / hz);
2124
return new StateSource(baseUrl ?? DefaultBaseUrl, pollInterval);
2225
}
@@ -39,6 +42,9 @@ public static StateSource CreateStateSource(HttpPollingSourceOptions options)
3942
/// <returns>A configured IndicatorsSource instance.</returns>
4043
public static IndicatorsSource CreateIndicatorsSource(string? baseUrl = null, int hz = 10)
4144
{
45+
if (hz <= 0)
46+
throw new ArgumentOutOfRangeException(nameof(hz), hz, "Polling frequency must be greater than 0");
47+
4248
var pollInterval = TimeSpan.FromMilliseconds(1000.0 / hz);
4349
return new IndicatorsSource(baseUrl ?? DefaultBaseUrl, pollInterval);
4450
}

0 commit comments

Comments
 (0)