diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingSockets.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingSockets.cs index 1b20868..02c413a 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingSockets.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingSockets.cs @@ -207,10 +207,10 @@ internal bool GetConnectionInfo( Connection hConn, ref ConnectionInfo pInfo ) #region FunctionMeta [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworkingSockets_GetQuickConnectionStatus", CallingConvention = Platform.CC)] [return: MarshalAs( UnmanagedType.I1 )] - private static extern bool _GetQuickConnectionStatus( IntPtr self, Connection hConn, ref SteamNetworkingQuickConnectionStatus pStats ); + private static extern bool _GetQuickConnectionStatus( IntPtr self, Connection hConn, ref ConnectionStatus pStats ); #endregion - internal bool GetQuickConnectionStatus( Connection hConn, ref SteamNetworkingQuickConnectionStatus pStats ) + internal bool GetQuickConnectionStatus( Connection hConn, ref ConnectionStatus pStats ) { var returnValue = _GetQuickConnectionStatus( Self, hConn, ref pStats ); return returnValue; diff --git a/Facepunch.Steamworks/Generated/SteamStructs.cs b/Facepunch.Steamworks/Generated/SteamStructs.cs index c7ad6a9..63d1efb 100644 --- a/Facepunch.Steamworks/Generated/SteamStructs.cs +++ b/Facepunch.Steamworks/Generated/SteamStructs.cs @@ -160,27 +160,6 @@ internal struct SteamItemDetails_t } - [StructLayout( LayoutKind.Sequential, Pack = Platform.StructPlatformPackSize )] - internal struct SteamNetworkingQuickConnectionStatus - { - internal ConnectionState State; // m_eState ESteamNetworkingConnectionState - internal int Ping; // m_nPing int - internal float ConnectionQualityLocal; // m_flConnectionQualityLocal float - internal float ConnectionQualityRemote; // m_flConnectionQualityRemote float - internal float OutPacketsPerSec; // m_flOutPacketsPerSec float - internal float OutBytesPerSec; // m_flOutBytesPerSec float - internal float InPacketsPerSec; // m_flInPacketsPerSec float - internal float InBytesPerSec; // m_flInBytesPerSec float - internal int SendRateBytesPerSecond; // m_nSendRateBytesPerSecond int - internal int CbPendingUnreliable; // m_cbPendingUnreliable int - internal int CbPendingReliable; // m_cbPendingReliable int - internal int CbSentUnackedReliable; // m_cbSentUnackedReliable int - internal long EcQueueTime; // m_usecQueueTime SteamNetworkingMicroseconds - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16, ArraySubType = UnmanagedType.U4)] - internal uint[] Reserved; // reserved uint32 [16] - - } - [StructLayout( LayoutKind.Sequential, Pack = Platform.StructPlatformPackSize )] internal partial struct SteamNetworkingPOPIDRender { diff --git a/Facepunch.Steamworks/Networking/Connection.cs b/Facepunch.Steamworks/Networking/Connection.cs index 439f6cd..e2843cd 100644 --- a/Facepunch.Steamworks/Networking/Connection.cs +++ b/Facepunch.Steamworks/Networking/Connection.cs @@ -122,5 +122,17 @@ public string DetailedStatus() return strVal; } + + /// + /// Returns a small set of information about the real-time state of the connection. + /// + public ConnectionStatus QuickStatus() + { + ConnectionStatus connectionStatus = default( ConnectionStatus ); + + SteamNetworkingSockets.Internal.GetQuickConnectionStatus( this, ref connectionStatus ); + + return connectionStatus; + } } } diff --git a/Facepunch.Steamworks/Networking/ConnectionStatus.cs b/Facepunch.Steamworks/Networking/ConnectionStatus.cs new file mode 100644 index 0000000..c217055 --- /dev/null +++ b/Facepunch.Steamworks/Networking/ConnectionStatus.cs @@ -0,0 +1,77 @@ +using System.Runtime.InteropServices; + +namespace Steamworks.Data +{ + /// + /// Describe the status of a connection + /// + [StructLayout( LayoutKind.Sequential, Pack = Platform.StructPlatformPackSize )] + public struct ConnectionStatus + { + internal ConnectionState state; // m_eState ESteamNetworkingConnectionState + internal int ping; // m_nPing int + internal float connectionQualityLocal; // m_flConnectionQualityLocal float + internal float connectionQualityRemote; // m_flConnectionQualityRemote float + internal float outPacketsPerSec; // m_flOutPacketsPerSec float + internal float outBytesPerSec; // m_flOutBytesPerSec float + internal float inPacketsPerSec; // m_flInPacketsPerSec float + internal float inBytesPerSec; // m_flInBytesPerSec float + internal int sendRateBytesPerSecond; // m_nSendRateBytesPerSecond int + internal int cbPendingUnreliable; // m_cbPendingUnreliable int + internal int cbPendingReliable; // m_cbPendingReliable int + internal int cbSentUnackedReliable; // m_cbSentUnackedReliable int + internal long ecQueueTime; // m_usecQueueTime SteamNetworkingMicroseconds + [MarshalAs( UnmanagedType.ByValArray, SizeConst = 16, ArraySubType = UnmanagedType.U4 )] + internal uint[] reserved; // reserved uint32 [16] + + /// + /// Current ping (ms) + /// + public int Ping => ping; + + /// + /// Outgoing packets per second + /// + public float OutPacketsPerSec => outPacketsPerSec; + + /// + /// Outgoing bytes per second + /// + public float OutBytesPerSec => outBytesPerSec; + + /// + /// Incoming packets per second + /// + public float InPacketsPerSec => inPacketsPerSec; + + /// + /// Incoming bytes per second + /// + public float InBytesPerSec => inBytesPerSec; + + /// + /// Connection quality measured locally, 0...1 (percentage of packets delivered end-to-end in order). + /// + public float ConnectionQualityLocal => connectionQualityLocal; + + /// + /// Packet delivery success rate as observed from remote host, 0...1 (percentage of packets delivered end-to-end in order). + /// + public float ConnectionQualityRemote => connectionQualityRemote; + + /// + /// Number of bytes unreliable data pending to be sent. This is data that you have recently requested to be sent but has not yet actually been put on the wire. + /// + public int PendingUnreliable => cbPendingUnreliable; + + /// + /// Number of bytes reliable data pending to be sent. This is data that you have recently requested to be sent but has not yet actually been put on the wire. + /// + public int PendingReliable => cbPendingReliable; + + /// + /// Number of bytes of reliable data that has been placed the wire, but for which we have not yet received an acknowledgment, and thus we may have to re-transmit. + /// + public int SentUnackedReliable => cbSentUnackedReliable; + } +} \ No newline at end of file diff --git a/Generator/Cleanup.cs b/Generator/Cleanup.cs index f30bb78..3a408b2 100644 --- a/Generator/Cleanup.cs +++ b/Generator/Cleanup.cs @@ -57,6 +57,7 @@ public static string ConvertType( string type ) type = type.Replace( "ISteamNetworkingMessage", "NetMsg" ); type = type.Replace( "SteamNetworkingMessage_t", "NetMsg" ); type = type.Replace( "SteamIPAddress_t", "SteamIPAddress" ); + type = type.Replace( "SteamNetworkingQuickConnectionStatus", "ConnectionStatus" ); type = type.Replace( "::", "." ); @@ -99,6 +100,7 @@ public static bool ShouldCreate( string type ) if ( type == "ValvePackingSentinel_t" ) return false; if ( type == "CCallbackBase" ) return false; if ( type == "CSteamGameServerAPIContext" ) return false; + if ( type == "ConnectionStatus") return false; return true; }