Skip to content

Commit

Permalink
Refactor to handle only IPv4 statistics
Browse files Browse the repository at this point in the history
Updated NetworkStatisticsModule.cs to focus solely on IPv4 statistics.
Modified comments and functionality in `GetActiveNetworkInterfaceAsync`
and `GetTotalBytes` methods to exclude IPv6 statistics. Removed lines
adding IPv6 stats in `GetTotalBytes` and unnecessary comments.
  • Loading branch information
BoiHanny committed Nov 30, 2024
1 parent cf978f5 commit 5e0de06
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions vrcosc-magicchatbox/Classes/Modules/NetworkStatisticsModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ private async Task InitializeNetworkStatsAsync()

/// <summary>
/// Asynchronously determines the active network interface.
/// Includes both IPv4 and IPv6 statistics.
/// Includes only IPv4 statistics.
/// </summary>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>The selected active NetworkInterface or null if none found.</returns>
Expand Down Expand Up @@ -240,18 +240,18 @@ private int GetInterfacePriority(NetworkInterface ni)
}

/// <summary>
/// Retrieves total bytes sent and received, including both IPv4 and IPv6.
/// Retrieves total bytes sent and received, including only IPv4 statistics.
/// </summary>
/// <param name="ni">NetworkInterface.</param>
/// <returns>TotalBytes struct containing BytesReceived and BytesSent.</returns>
private TotalBytes GetTotalBytes(NetworkInterface ni)
{
var ipv4Stats = ni.GetIPv4Statistics();
var ipv6Stats = ni.GetIPStatistics();
// Removed IPv6 statistics to avoid duplication
return new TotalBytes
{
BytesReceived = ipv4Stats.BytesReceived + ipv6Stats.BytesReceived,
BytesSent = ipv4Stats.BytesSent + ipv6Stats.BytesSent
BytesReceived = ipv4Stats.BytesReceived,
BytesSent = ipv4Stats.BytesSent
};
}

Expand Down Expand Up @@ -297,7 +297,6 @@ private void OnTimedEvent(object state)
{
if (_activeNetworkInterface == null)
{
// Attempt to re-initialize if the active interface is null
InitializeNetworkStatsAsync().ConfigureAwait(false);
if (_activeNetworkInterface == null)
return;
Expand Down

0 comments on commit 5e0de06

Please sign in to comment.