From e7a6a00675dd462dfe6c35c8c91a8b126450d95c Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Mon, 24 Feb 2020 08:58:09 +0000 Subject: [PATCH] Networking Cleanup --- Facepunch.Steamworks.Test/NetworkingUtils.cs | 4 +-- .../Interfaces/ISteamNetworkingSockets.cs | 8 ++--- .../Interfaces/ISteamNetworkingUtils.cs | 24 ++++++------- Facepunch.Steamworks/Generated/SteamEnums.cs | 4 +-- .../Generated/SteamStructs.cs | 21 +++++++++++ .../{Structs => Networking}/Connection.cs | 16 ++++++++- .../{Structs => Networking}/ConnectionInfo.cs | 16 ++++++++- .../ConnectionInterface.cs | 0 .../{Structs => Networking}/NetAddress.cs | 0 .../Networking/NetDebugFunc.cs | 8 +++++ .../NetErrorMessage.cs} | 3 +- .../{Structs => Networking}/NetIdentity.cs | 0 .../{Structs => Networking}/NetKeyValue.cs | 0 .../{Structs => Networking}/NetMsg.cs | 0 .../NetPingLocation.cs} | 8 ++--- .../{Structs => Networking}/Socket.cs | 0 .../SocketInterface.cs | 8 ++++- .../SteamDatagramRelayAuthTicket.cs | 12 +++++++ Facepunch.Steamworks/SteamNetworkingUtils.cs | 6 ++-- Facepunch.Steamworks/SteamParties.cs | 21 ++++------- .../Structs/SteamNetworking.cs | 35 ------------------- Facepunch.Steamworks/Structs/Ugc.cs | 6 +++- Facepunch.Steamworks/Utility/Utf8String.cs | 2 ++ Generator/Cleanup.cs | 13 ++++--- 24 files changed, 128 insertions(+), 87 deletions(-) rename Facepunch.Steamworks/{Structs => Networking}/Connection.cs (85%) rename Facepunch.Steamworks/{Structs => Networking}/ConnectionInfo.cs (61%) rename Facepunch.Steamworks/{Classes => Networking}/ConnectionInterface.cs (100%) rename Facepunch.Steamworks/{Structs => Networking}/NetAddress.cs (100%) create mode 100644 Facepunch.Steamworks/Networking/NetDebugFunc.cs rename Facepunch.Steamworks/{Structs/SteamNetworkingErrMsg.cs => Networking/NetErrorMessage.cs} (66%) rename Facepunch.Steamworks/{Structs => Networking}/NetIdentity.cs (100%) rename Facepunch.Steamworks/{Structs => Networking}/NetKeyValue.cs (100%) rename Facepunch.Steamworks/{Structs => Networking}/NetMsg.cs (100%) rename Facepunch.Steamworks/{Structs/PingLocation.cs => Networking/NetPingLocation.cs} (93%) rename Facepunch.Steamworks/{Structs => Networking}/Socket.cs (100%) rename Facepunch.Steamworks/{Classes => Networking}/SocketInterface.cs (92%) create mode 100644 Facepunch.Steamworks/Networking/SteamDatagramRelayAuthTicket.cs delete mode 100644 Facepunch.Steamworks/Structs/SteamNetworking.cs diff --git a/Facepunch.Steamworks.Test/NetworkingUtils.cs b/Facepunch.Steamworks.Test/NetworkingUtils.cs index 2c84ed7..d2f7fb6 100644 --- a/Facepunch.Steamworks.Test/NetworkingUtils.cs +++ b/Facepunch.Steamworks.Test/NetworkingUtils.cs @@ -38,7 +38,7 @@ public async Task LocalPingLocation() [TestMethod] public void PingLocationParse() { - var pl = Data.PingLocation.TryParseFromString( GarrysLocation ); + var pl = Data.NetPingLocation.TryParseFromString( GarrysLocation ); Assert.IsTrue( pl.HasValue ); @@ -50,7 +50,7 @@ public async Task GetEstimatedPing() { await SteamNetworkingUtils.WaitForPingDataAsync(); - var garrysping = Data.PingLocation.TryParseFromString( GarrysLocation ); + var garrysping = Data.NetPingLocation.TryParseFromString( GarrysLocation ); Assert.IsTrue( garrysping.HasValue ); var ping = SteamNetworkingUtils.EstimatePingTo( garrysping.Value ); diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingSockets.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingSockets.cs index d6cd2f7..1b20868 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingSockets.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingSockets.cs @@ -448,10 +448,10 @@ internal bool ReceivedP2PCustomSignal( IntPtr pMsg, int cbMsg, IntPtr pContext ) #region FunctionMeta [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworkingSockets_GetCertificateRequest", CallingConvention = Platform.CC)] [return: MarshalAs( UnmanagedType.I1 )] - private static extern bool _GetCertificateRequest( IntPtr self, ref int pcbBlob, IntPtr pBlob, ref SteamNetworkingErrMsg errMsg ); + private static extern bool _GetCertificateRequest( IntPtr self, ref int pcbBlob, IntPtr pBlob, ref NetErrorMessage errMsg ); #endregion - internal bool GetCertificateRequest( ref int pcbBlob, IntPtr pBlob, ref SteamNetworkingErrMsg errMsg ) + internal bool GetCertificateRequest( ref int pcbBlob, IntPtr pBlob, ref NetErrorMessage errMsg ) { var returnValue = _GetCertificateRequest( Self, ref pcbBlob, pBlob, ref errMsg ); return returnValue; @@ -460,10 +460,10 @@ internal bool GetCertificateRequest( ref int pcbBlob, IntPtr pBlob, ref SteamNet #region FunctionMeta [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworkingSockets_SetCertificate", CallingConvention = Platform.CC)] [return: MarshalAs( UnmanagedType.I1 )] - private static extern bool _SetCertificate( IntPtr self, IntPtr pCertificate, int cbCertificate, ref SteamNetworkingErrMsg errMsg ); + private static extern bool _SetCertificate( IntPtr self, IntPtr pCertificate, int cbCertificate, ref NetErrorMessage errMsg ); #endregion - internal bool SetCertificate( IntPtr pCertificate, int cbCertificate, ref SteamNetworkingErrMsg errMsg ) + internal bool SetCertificate( IntPtr pCertificate, int cbCertificate, ref NetErrorMessage errMsg ) { var returnValue = _SetCertificate( Self, pCertificate, cbCertificate, ref errMsg ); return returnValue; diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingUtils.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingUtils.cs index 30f265b..6c65ae3 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingUtils.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingUtils.cs @@ -54,10 +54,10 @@ internal SteamNetworkingAvailability GetRelayNetworkStatus( ref SteamRelayNetwor #region FunctionMeta [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworkingUtils_GetLocalPingLocation", CallingConvention = Platform.CC)] - private static extern float _GetLocalPingLocation( IntPtr self, ref PingLocation result ); + private static extern float _GetLocalPingLocation( IntPtr self, ref NetPingLocation result ); #endregion - internal float GetLocalPingLocation( ref PingLocation result ) + internal float GetLocalPingLocation( ref NetPingLocation result ) { var returnValue = _GetLocalPingLocation( Self, ref result ); return returnValue; @@ -65,10 +65,10 @@ internal float GetLocalPingLocation( ref PingLocation result ) #region FunctionMeta [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworkingUtils_EstimatePingTimeBetweenTwoLocations", CallingConvention = Platform.CC)] - private static extern int _EstimatePingTimeBetweenTwoLocations( IntPtr self, ref PingLocation location1, ref PingLocation location2 ); + private static extern int _EstimatePingTimeBetweenTwoLocations( IntPtr self, ref NetPingLocation location1, ref NetPingLocation location2 ); #endregion - internal int EstimatePingTimeBetweenTwoLocations( ref PingLocation location1, ref PingLocation location2 ) + internal int EstimatePingTimeBetweenTwoLocations( ref NetPingLocation location1, ref NetPingLocation location2 ) { var returnValue = _EstimatePingTimeBetweenTwoLocations( Self, ref location1, ref location2 ); return returnValue; @@ -76,10 +76,10 @@ internal int EstimatePingTimeBetweenTwoLocations( ref PingLocation location1, re #region FunctionMeta [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworkingUtils_EstimatePingTimeFromLocalHost", CallingConvention = Platform.CC)] - private static extern int _EstimatePingTimeFromLocalHost( IntPtr self, ref PingLocation remoteLocation ); + private static extern int _EstimatePingTimeFromLocalHost( IntPtr self, ref NetPingLocation remoteLocation ); #endregion - internal int EstimatePingTimeFromLocalHost( ref PingLocation remoteLocation ) + internal int EstimatePingTimeFromLocalHost( ref NetPingLocation remoteLocation ) { var returnValue = _EstimatePingTimeFromLocalHost( Self, ref remoteLocation ); return returnValue; @@ -87,10 +87,10 @@ internal int EstimatePingTimeFromLocalHost( ref PingLocation remoteLocation ) #region FunctionMeta [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworkingUtils_ConvertPingLocationToString", CallingConvention = Platform.CC)] - private static extern void _ConvertPingLocationToString( IntPtr self, ref PingLocation location, IntPtr pszBuf, int cchBufSize ); + private static extern void _ConvertPingLocationToString( IntPtr self, ref NetPingLocation location, IntPtr pszBuf, int cchBufSize ); #endregion - internal void ConvertPingLocationToString( ref PingLocation location, out string pszBuf ) + internal void ConvertPingLocationToString( ref NetPingLocation location, out string pszBuf ) { IntPtr mempszBuf = Helpers.TakeMemory(); _ConvertPingLocationToString( Self, ref location, mempszBuf, (1024 * 32) ); @@ -100,10 +100,10 @@ internal void ConvertPingLocationToString( ref PingLocation location, out string #region FunctionMeta [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworkingUtils_ParsePingLocationString", CallingConvention = Platform.CC)] [return: MarshalAs( UnmanagedType.I1 )] - private static extern bool _ParsePingLocationString( IntPtr self, [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string pszString, ref PingLocation result ); + private static extern bool _ParsePingLocationString( IntPtr self, [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string pszString, ref NetPingLocation result ); #endregion - internal bool ParsePingLocationString( [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string pszString, ref PingLocation result ) + internal bool ParsePingLocationString( [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string pszString, ref NetPingLocation result ) { var returnValue = _ParsePingLocationString( Self, pszString, ref result ); return returnValue; @@ -178,10 +178,10 @@ internal long GetLocalTimestamp() #region FunctionMeta [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworkingUtils_SetDebugOutputFunction", CallingConvention = Platform.CC)] - private static extern void _SetDebugOutputFunction( IntPtr self, DebugOutputType eDetailLevel, FSteamNetworkingSocketsDebugOutput pfnFunc ); + private static extern void _SetDebugOutputFunction( IntPtr self, DebugOutputType eDetailLevel, NetDebugFunc pfnFunc ); #endregion - internal void SetDebugOutputFunction( DebugOutputType eDetailLevel, FSteamNetworkingSocketsDebugOutput pfnFunc ) + internal void SetDebugOutputFunction( DebugOutputType eDetailLevel, NetDebugFunc pfnFunc ) { _SetDebugOutputFunction( Self, eDetailLevel, pfnFunc ); } diff --git a/Facepunch.Steamworks/Generated/SteamEnums.cs b/Facepunch.Steamworks/Generated/SteamEnums.cs index ef706c9..cc73dea 100644 --- a/Facepunch.Steamworks/Generated/SteamEnums.cs +++ b/Facepunch.Steamworks/Generated/SteamEnums.cs @@ -526,7 +526,7 @@ internal enum MarketNotAllowedReasonFlags : int // // EDurationControlProgress // - internal enum DurationControlProgress : int + public enum DurationControlProgress : int { Progress_Full = 0, Progress_Half = 1, @@ -1988,7 +1988,7 @@ public enum ConnectionState : int // // ESteamNetConnectionEnd // - internal enum SteamNetConnectionEnd : int + public enum NetConnectionEnd : int { Invalid = 0, App_Min = 1000, diff --git a/Facepunch.Steamworks/Generated/SteamStructs.cs b/Facepunch.Steamworks/Generated/SteamStructs.cs index 0660d98..545f38d 100644 --- a/Facepunch.Steamworks/Generated/SteamStructs.cs +++ b/Facepunch.Steamworks/Generated/SteamStructs.cs @@ -178,6 +178,27 @@ internal struct SteamTVRegion_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 struct SteamDatagramHostedAddress { diff --git a/Facepunch.Steamworks/Structs/Connection.cs b/Facepunch.Steamworks/Networking/Connection.cs similarity index 85% rename from Facepunch.Steamworks/Structs/Connection.cs rename to Facepunch.Steamworks/Networking/Connection.cs index eaac660..147d37e 100644 --- a/Facepunch.Steamworks/Structs/Connection.cs +++ b/Facepunch.Steamworks/Networking/Connection.cs @@ -3,6 +3,14 @@ namespace Steamworks.Data { + + /// + /// Used as a base to create your client connection. This creates a socket + /// to a single connection. + /// + /// You can override all the virtual functions to turn it into what you + /// want it to do. + /// public struct Connection { public uint Id { get; set; } @@ -83,10 +91,16 @@ public unsafe Result SendMessage( string str, SendType sendType = SendType.Relia } /// - /// Flush any messages waiting on the Nagle timer and send them at the next transmission opportunity (often that means right now). + /// Flush any messages waiting on the Nagle timer and send them at the next transmission + /// opportunity (often that means right now). /// public Result Flush() => SteamNetworkingSockets.Internal.FlushMessagesOnConnection( this ); + /// + /// Returns detailed connection stats in text format. Useful + /// for dumping to a log, etc. + /// + /// Plain text connection info public string DetailedStatus() { if ( SteamNetworkingSockets.Internal.GetDetailedConnectionStatus( this, out var strVal ) != 0 ) diff --git a/Facepunch.Steamworks/Structs/ConnectionInfo.cs b/Facepunch.Steamworks/Networking/ConnectionInfo.cs similarity index 61% rename from Facepunch.Steamworks/Structs/ConnectionInfo.cs rename to Facepunch.Steamworks/Networking/ConnectionInfo.cs index 6cbdf22..dccbf24 100644 --- a/Facepunch.Steamworks/Structs/ConnectionInfo.cs +++ b/Facepunch.Steamworks/Networking/ConnectionInfo.cs @@ -2,6 +2,9 @@ namespace Steamworks.Data { + /// + /// Describe the state of a connection + /// [StructLayout( LayoutKind.Sequential, Size = 696 )] public struct ConnectionInfo { @@ -19,8 +22,19 @@ public struct ConnectionInfo [MarshalAs( UnmanagedType.ByValTStr, SizeConst = 128 )] internal string connectionDescription; + /// + /// High level state of the connection + /// public ConnectionState State => state; + + /// + /// Who is on the other end? Depending on the connection type and phase of the connection, we might not know + /// public SteamId SteamId => identity.steamID; - public int EndReason => endReason; + + /// + /// Basic cause of the connection termination or problem. + /// + public NetConnectionEnd EndReason => (NetConnectionEnd)endReason; } } \ No newline at end of file diff --git a/Facepunch.Steamworks/Classes/ConnectionInterface.cs b/Facepunch.Steamworks/Networking/ConnectionInterface.cs similarity index 100% rename from Facepunch.Steamworks/Classes/ConnectionInterface.cs rename to Facepunch.Steamworks/Networking/ConnectionInterface.cs diff --git a/Facepunch.Steamworks/Structs/NetAddress.cs b/Facepunch.Steamworks/Networking/NetAddress.cs similarity index 100% rename from Facepunch.Steamworks/Structs/NetAddress.cs rename to Facepunch.Steamworks/Networking/NetAddress.cs diff --git a/Facepunch.Steamworks/Networking/NetDebugFunc.cs b/Facepunch.Steamworks/Networking/NetDebugFunc.cs new file mode 100644 index 0000000..9c47c8b --- /dev/null +++ b/Facepunch.Steamworks/Networking/NetDebugFunc.cs @@ -0,0 +1,8 @@ +using Steamworks.Data; +using System; +using System.Runtime.InteropServices; + +namespace Steamworks.Data +{ + delegate void NetDebugFunc( DebugOutputType nType, string pszMsg ); +} \ No newline at end of file diff --git a/Facepunch.Steamworks/Structs/SteamNetworkingErrMsg.cs b/Facepunch.Steamworks/Networking/NetErrorMessage.cs similarity index 66% rename from Facepunch.Steamworks/Structs/SteamNetworkingErrMsg.cs rename to Facepunch.Steamworks/Networking/NetErrorMessage.cs index 692528d..685a43d 100644 --- a/Facepunch.Steamworks/Structs/SteamNetworkingErrMsg.cs +++ b/Facepunch.Steamworks/Networking/NetErrorMessage.cs @@ -3,8 +3,7 @@ namespace Steamworks.Data { - - internal unsafe struct SteamNetworkingErrMsg + internal unsafe struct NetErrorMessage { public fixed char Value[1024]; } diff --git a/Facepunch.Steamworks/Structs/NetIdentity.cs b/Facepunch.Steamworks/Networking/NetIdentity.cs similarity index 100% rename from Facepunch.Steamworks/Structs/NetIdentity.cs rename to Facepunch.Steamworks/Networking/NetIdentity.cs diff --git a/Facepunch.Steamworks/Structs/NetKeyValue.cs b/Facepunch.Steamworks/Networking/NetKeyValue.cs similarity index 100% rename from Facepunch.Steamworks/Structs/NetKeyValue.cs rename to Facepunch.Steamworks/Networking/NetKeyValue.cs diff --git a/Facepunch.Steamworks/Structs/NetMsg.cs b/Facepunch.Steamworks/Networking/NetMsg.cs similarity index 100% rename from Facepunch.Steamworks/Structs/NetMsg.cs rename to Facepunch.Steamworks/Networking/NetMsg.cs diff --git a/Facepunch.Steamworks/Structs/PingLocation.cs b/Facepunch.Steamworks/Networking/NetPingLocation.cs similarity index 93% rename from Facepunch.Steamworks/Structs/PingLocation.cs rename to Facepunch.Steamworks/Networking/NetPingLocation.cs index 9eb0a95..9aceca5 100644 --- a/Facepunch.Steamworks/Structs/PingLocation.cs +++ b/Facepunch.Steamworks/Networking/NetPingLocation.cs @@ -20,11 +20,11 @@ namespace Steamworks.Data /// /// [StructLayout( LayoutKind.Explicit, Size = 512 )] - public struct PingLocation + public struct NetPingLocation { - public static PingLocation? TryParseFromString( string str ) + public static NetPingLocation? TryParseFromString( string str ) { - var result = default( PingLocation ); + var result = default( NetPingLocation ); if ( !SteamNetworkingUtils.Internal.ParsePingLocationString( str, ref result ) ) return null; @@ -59,7 +59,7 @@ public override string ToString() /// /// Do you need to be able to do this from a backend/matchmaking server? /// You are looking for the "ticketgen" library. - public int EstimatePingTo( PingLocation target ) + public int EstimatePingTo( NetPingLocation target ) { return SteamNetworkingUtils.Internal.EstimatePingTimeBetweenTwoLocations( ref this, ref target ); } diff --git a/Facepunch.Steamworks/Structs/Socket.cs b/Facepunch.Steamworks/Networking/Socket.cs similarity index 100% rename from Facepunch.Steamworks/Structs/Socket.cs rename to Facepunch.Steamworks/Networking/Socket.cs diff --git a/Facepunch.Steamworks/Classes/SocketInterface.cs b/Facepunch.Steamworks/Networking/SocketInterface.cs similarity index 92% rename from Facepunch.Steamworks/Classes/SocketInterface.cs rename to Facepunch.Steamworks/Networking/SocketInterface.cs index 44c13c7..32d0519 100644 --- a/Facepunch.Steamworks/Classes/SocketInterface.cs +++ b/Facepunch.Steamworks/Networking/SocketInterface.cs @@ -5,6 +5,13 @@ namespace Steamworks { + /// + /// Used as a base to create your networking server. This creates a socket + /// and listens/communicates with multiple queries. + /// + /// You can override all the virtual functions to turn it into what you + /// want it to do. + /// public class SocketInterface { public List Connecting = new List(); @@ -87,7 +94,6 @@ public void Receive( int bufferSize = 32 ) int processed = 0; IntPtr messageBuffer = Marshal.AllocHGlobal( IntPtr.Size * bufferSize ); - try { processed = SteamNetworkingSockets.Internal.ReceiveMessagesOnPollGroup( pollGroup, messageBuffer, bufferSize ); diff --git a/Facepunch.Steamworks/Networking/SteamDatagramRelayAuthTicket.cs b/Facepunch.Steamworks/Networking/SteamDatagramRelayAuthTicket.cs new file mode 100644 index 0000000..8a95234 --- /dev/null +++ b/Facepunch.Steamworks/Networking/SteamDatagramRelayAuthTicket.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; + +namespace Steamworks.Data +{ + struct SteamDatagramRelayAuthTicket + { + // Not implemented, not used + }; +} \ No newline at end of file diff --git a/Facepunch.Steamworks/SteamNetworkingUtils.cs b/Facepunch.Steamworks/SteamNetworkingUtils.cs index aa44ea8..b6899ef 100644 --- a/Facepunch.Steamworks/SteamNetworkingUtils.cs +++ b/Facepunch.Steamworks/SteamNetworkingUtils.cs @@ -66,11 +66,11 @@ public static void InitRelayNetworkAccess() /// This always return the most up-to-date information we have available /// right now, even if we are in the middle of re-calculating ping times. /// - public static PingLocation? LocalPingLocation + public static NetPingLocation? LocalPingLocation { get { - PingLocation location = default; + NetPingLocation location = default; var age = Internal.GetLocalPingLocation( ref location ); if ( age < 0 ) return null; @@ -84,7 +84,7 @@ public static PingLocation? LocalPingLocation /// This is a bit faster, especially if you need to calculate a bunch of /// these in a loop to find the fastest one. /// - public static int EstimatePingTo( PingLocation target ) + public static int EstimatePingTo( NetPingLocation target ) { return Internal.EstimatePingTimeFromLocalHost( ref target ); } diff --git a/Facepunch.Steamworks/SteamParties.cs b/Facepunch.Steamworks/SteamParties.cs index 6b972d0..aef57bb 100644 --- a/Facepunch.Steamworks/SteamParties.cs +++ b/Facepunch.Steamworks/SteamParties.cs @@ -7,6 +7,12 @@ namespace Steamworks { + /// + /// This API can be used to selectively advertise your multiplayer game session in a Steam chat room group. + /// Tell Steam the number of player spots that are available for your party, and a join-game string, and it + /// will show a beacon in the selected group and allow that many users to “follow” the beacon to your party. + /// Adjust the number of open slots if other players join through alternate matchmaking methods. + /// public class SteamParties : SteamClientClass { internal static ISteamParties Internal => Interface as ISteamParties; @@ -17,7 +23,7 @@ internal override void InitializeInterface( bool server ) InstallEvents( server ); } - internal static void InstallEvents( bool server ) + internal void InstallEvents( bool server ) { Dispatch.Install( x => OnBeaconLocationsUpdated?.Invoke(), server ); Dispatch.Install( x => OnActiveBeaconsUpdated?.Invoke(), server ); @@ -49,18 +55,5 @@ public static IEnumerable ActiveBeacons } } } - - /// - /// Create a new party beacon and activate it in the selected location. - /// When people begin responding to your beacon, Steam will send you - /// OnPartyReservation callbacks to let you know who is on the way. - /// - //public async Task CreateBeacon( int slots, string connectString, string meta ) - //{ - // var result = await Internal.CreateBeacon( (uint)slots, null, connectString, meta ); - // if ( !result.HasValue ) return null; - //} - - // TODO - is this useful to anyone, or is it a load of shit? } } \ No newline at end of file diff --git a/Facepunch.Steamworks/Structs/SteamNetworking.cs b/Facepunch.Steamworks/Structs/SteamNetworking.cs deleted file mode 100644 index 62e9356..0000000 --- a/Facepunch.Steamworks/Structs/SteamNetworking.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Text; - -namespace Steamworks.Data -{ - delegate void FSteamNetworkingSocketsDebugOutput (DebugOutputType nType, string pszMsg ); - - [StructLayout( LayoutKind.Sequential )] - public struct SteamNetworkingQuickConnectionStatus - { - public ConnectionState state; - public int ping; - public float connectionQualityLocal; - public float connectionQualityRemote; - public float outPacketsPerSecond; - public float outBytesPerSecond; - public float inPacketsPerSecond; - public float inBytesPerSecond; - public int sendRateBytesPerSecond; - public int pendingUnreliable; - public int pendingReliable; - public int sentUnackedReliable; - public long queueTime; - - [MarshalAs( UnmanagedType.ByValArray, SizeConst = 16 )] - uint[] reserved; - } - - struct SteamDatagramRelayAuthTicket - { - // Not implemented - }; -} \ No newline at end of file diff --git a/Facepunch.Steamworks/Structs/Ugc.cs b/Facepunch.Steamworks/Structs/Ugc.cs index f902b33..20a459b 100644 --- a/Facepunch.Steamworks/Structs/Ugc.cs +++ b/Facepunch.Steamworks/Structs/Ugc.cs @@ -1,9 +1,13 @@ using System.Linq; +#pragma warning disable 649 + namespace Steamworks.Data { public struct Ugc { internal UGCHandle_t Handle; } -} \ No newline at end of file +} + +#pragma warning restore 649 diff --git a/Facepunch.Steamworks/Utility/Utf8String.cs b/Facepunch.Steamworks/Utility/Utf8String.cs index ac73835..3599753 100644 --- a/Facepunch.Steamworks/Utility/Utf8String.cs +++ b/Facepunch.Steamworks/Utility/Utf8String.cs @@ -44,7 +44,9 @@ public IntPtr MarshalManagedToNative(object managedObj) internal struct Utf8StringPointer { +#pragma warning disable 649 internal IntPtr ptr; +#pragma warning restore 649 public unsafe static implicit operator string( Utf8StringPointer p ) { diff --git a/Generator/Cleanup.cs b/Generator/Cleanup.cs index 6afb829..4d76f1e 100644 --- a/Generator/Cleanup.cs +++ b/Generator/Cleanup.cs @@ -32,11 +32,14 @@ public static string ConvertType( string type ) type = type.Replace( "SteamItemInstanceID_t", "InventoryItemId" ); type = type.Replace( "SteamItemDef_t", "InventoryDefId" ); type = type.Replace( "ChatRoomEnterResponse", "RoomEnter" ); - type = type.Replace( "SteamNetworkPingLocation_t", "PingLocation" ); + type = type.Replace( "SteamNetworkPingLocation_t", "NetPingLocation" ); type = type.Replace( "SteamNetworkingConfigValue_t", "NetKeyValue" ); type = type.Replace( "SteamNetworkingConfigValue", "NetConfig" ); type = type.Replace( "SteamNetworkingConfigScope", "NetConfigScope" ); type = type.Replace( "SteamNetworkingConfigDataType", "NetConfigType" ); + type = type.Replace( "FSteamNetworkingSocketsDebugOutput", "NetDebugFunc" ); + type = type.Replace( "SteamNetworkingErrMsg", "NetErrorMessage" ); + type = type.Replace( "SteamNetConnectionEnd", "NetConnectionEnd" ); type = type.Replace( "HSteamNetConnection", "Connection" ); type = type.Replace( "HSteamListenSocket", "Socket" ); type = type.Replace( "SteamNetworkingIPAddr", "NetAddress" ); @@ -77,18 +80,17 @@ public static bool ShouldCreate( string type ) if ( type == "Connection" ) return false; if ( type == "Socket" ) return false; if ( type == "SteamNetworkingMicroseconds" ) return false; - if ( type == "FSteamNetworkingSocketsDebugOutput" ) return false; + if ( type == "NetDebugFunc" ) return false; if ( type == "NetMsg" ) return false; if ( type == "SteamDatagramErrMsg" ) return false; if ( type == "ConnectionInfo" ) return false; if ( type == "SteamNetworkingIPAddr" ) return false; if ( type == "NetAddress" ) return false; if ( type == "NetIdentity" ) return false; - if ( type == "SteamNetworkingQuickConnectionStatus" ) return false; if ( type == "SteamNetworkingErrMsg" ) return false; if ( type == "NetKeyValue" ) return false; if ( type == "SteamIPAddress" ) return false; - if ( type == "PingLocation" ) return false; + if ( type == "NetPingLocation" ) return false; if ( type == "CSteamID" ) return false; if ( type == "CSteamAPIContext" ) return false; if ( type == "CCallResult" ) return false; @@ -126,11 +128,12 @@ internal static string Expose( string name ) if ( name == "InputType" ) return "public"; if ( name == "InputSourceMode" ) return "public"; if ( name == "UserHasLicenseForAppResult" ) return "public"; - if ( name == "PingLocation" ) return "public"; + if ( name == "NetPingLocation" ) return "public"; if ( name == "ConnectionState" ) return "public"; if ( name == "SteamNetworkingAvailability" ) return "public"; if ( name == "SteamDeviceFormFactor" ) return "public"; if ( name == "DurationControlProgress" ) return "public"; + if ( name == "NetConnectionEnd" ) return "public"; return "internal"; }