mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-26 14:45:51 +03:00
Connection.QuickStatus implementation
This commit is contained in:
parent
c4ffb5eac7
commit
f887d8a9ba
@ -207,10 +207,10 @@ internal bool GetConnectionInfo( Connection hConn, ref ConnectionInfo pInfo )
|
|||||||
#region FunctionMeta
|
#region FunctionMeta
|
||||||
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworkingSockets_GetQuickConnectionStatus", CallingConvention = Platform.CC)]
|
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworkingSockets_GetQuickConnectionStatus", CallingConvention = Platform.CC)]
|
||||||
[return: MarshalAs( UnmanagedType.I1 )]
|
[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
|
#endregion
|
||||||
internal bool GetQuickConnectionStatus( Connection hConn, ref SteamNetworkingQuickConnectionStatus pStats )
|
internal bool GetQuickConnectionStatus( Connection hConn, ref ConnectionStatus pStats )
|
||||||
{
|
{
|
||||||
var returnValue = _GetQuickConnectionStatus( Self, hConn, ref pStats );
|
var returnValue = _GetQuickConnectionStatus( Self, hConn, ref pStats );
|
||||||
return returnValue;
|
return returnValue;
|
||||||
|
@ -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 )]
|
[StructLayout( LayoutKind.Sequential, Pack = Platform.StructPlatformPackSize )]
|
||||||
internal partial struct SteamNetworkingPOPIDRender
|
internal partial struct SteamNetworkingPOPIDRender
|
||||||
{
|
{
|
||||||
|
@ -122,5 +122,17 @@ public string DetailedStatus()
|
|||||||
|
|
||||||
return strVal;
|
return strVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a small set of information about the real-time state of the connection.
|
||||||
|
/// </summary>
|
||||||
|
public ConnectionStatus QuickStatus()
|
||||||
|
{
|
||||||
|
ConnectionStatus connectionStatus = default( ConnectionStatus );
|
||||||
|
|
||||||
|
SteamNetworkingSockets.Internal.GetQuickConnectionStatus( this, ref connectionStatus );
|
||||||
|
|
||||||
|
return connectionStatus;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
77
Facepunch.Steamworks/Networking/ConnectionStatus.cs
Normal file
77
Facepunch.Steamworks/Networking/ConnectionStatus.cs
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace Steamworks.Data
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Describe the status of a connection
|
||||||
|
/// </summary>
|
||||||
|
[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]
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Current ping (ms)
|
||||||
|
/// </summary>
|
||||||
|
public int Ping => ping;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Outgoing packets per second
|
||||||
|
/// </summary>
|
||||||
|
public float OutPacketsPerSec => outPacketsPerSec;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Outgoing bytes per second
|
||||||
|
/// </summary>
|
||||||
|
public float OutBytesPerSec => outBytesPerSec;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Incoming packets per second
|
||||||
|
/// </summary>
|
||||||
|
public float InPacketsPerSec => inPacketsPerSec;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Incoming bytes per second
|
||||||
|
/// </summary>
|
||||||
|
public float InBytesPerSec => inBytesPerSec;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Connection quality measured locally, 0...1 (percentage of packets delivered end-to-end in order).
|
||||||
|
/// </summary>
|
||||||
|
public float ConnectionQualityLocal => connectionQualityLocal;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Packet delivery success rate as observed from remote host, 0...1 (percentage of packets delivered end-to-end in order).
|
||||||
|
/// </summary>
|
||||||
|
public float ConnectionQualityRemote => connectionQualityRemote;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
public int PendingUnreliable => cbPendingUnreliable;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
public int PendingReliable => cbPendingReliable;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
public int SentUnackedReliable => cbSentUnackedReliable;
|
||||||
|
}
|
||||||
|
}
|
@ -57,6 +57,7 @@ public static string ConvertType( string type )
|
|||||||
type = type.Replace( "ISteamNetworkingMessage", "NetMsg" );
|
type = type.Replace( "ISteamNetworkingMessage", "NetMsg" );
|
||||||
type = type.Replace( "SteamNetworkingMessage_t", "NetMsg" );
|
type = type.Replace( "SteamNetworkingMessage_t", "NetMsg" );
|
||||||
type = type.Replace( "SteamIPAddress_t", "SteamIPAddress" );
|
type = type.Replace( "SteamIPAddress_t", "SteamIPAddress" );
|
||||||
|
type = type.Replace( "SteamNetworkingQuickConnectionStatus", "ConnectionStatus" );
|
||||||
|
|
||||||
type = type.Replace( "::", "." );
|
type = type.Replace( "::", "." );
|
||||||
|
|
||||||
@ -99,6 +100,7 @@ public static bool ShouldCreate( string type )
|
|||||||
if ( type == "ValvePackingSentinel_t" ) return false;
|
if ( type == "ValvePackingSentinel_t" ) return false;
|
||||||
if ( type == "CCallbackBase" ) return false;
|
if ( type == "CCallbackBase" ) return false;
|
||||||
if ( type == "CSteamGameServerAPIContext" ) return false;
|
if ( type == "CSteamGameServerAPIContext" ) return false;
|
||||||
|
if ( type == "ConnectionStatus") return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user