From 87ff387ca6077994534e4a49bf137d7c0ce44fc3 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Thu, 2 May 2019 13:05:56 +0100 Subject: [PATCH] SteamNetworking enum/structs --- Facepunch.Steamworks/Enum/SteamNetworking.cs | 104 ++++++++++++++++++ .../Structs/SteamNetworking.cs | 66 +++++++++++ 2 files changed, 170 insertions(+) create mode 100644 Facepunch.Steamworks/Enum/SteamNetworking.cs create mode 100644 Facepunch.Steamworks/Structs/SteamNetworking.cs diff --git a/Facepunch.Steamworks/Enum/SteamNetworking.cs b/Facepunch.Steamworks/Enum/SteamNetworking.cs new file mode 100644 index 0000000..b77a17e --- /dev/null +++ b/Facepunch.Steamworks/Enum/SteamNetworking.cs @@ -0,0 +1,104 @@ +namespace Steamworks.Data +{ + enum SteamNetworkingGetConfigValueResult + { + BadValue = -1, // No such configuration value + BadScopeObj = -2, // Bad connection handle, etc + BufferTooSmall = -3, // Couldn't fit the result in your buffer + OK = 1, + OKInherited = 2, // A value was not set at this level, but the effective (inherited) value was returned. + + Force32Bit = 0x7fffffff + }; + + enum SteamNetworkingConfigDataType + { + Int32 = 1, + Int64 = 2, + Float = 3, + String = 4, + FunctionPtr = 5, // NOTE: When setting callbacks, you should put the pointer into a variable and pass a pointer to that variable. + + Force32Bit = 0x7fffffff + }; + + enum SteamNetworkingSocketsDebugOutputType : int + { + None = 0, + Bug = 1, // You used the API incorrectly, or an internal error happened + Error = 2, // Run-time error condition that isn't the result of a bug. (E.g. we are offline, cannot bind a port, etc) + Important = 3, // Nothing is wrong, but this is an important notification + Warning = 4, + Msg = 5, // Recommended amount + Verbose = 6, // Quite a bit + Debug = 7, // Practically everything + Everything = 8, // Wall of text, detailed packet contents breakdown, etc + + Force32Bit = 0x7fffffff + }; + + internal enum SteamNetworkingConfigScope : int + { + Global = 1, + SocketsInterface = 2, + ListenSocket = 3, + Connection = 4, + + Force32Bit = 0x7fffffff + } + + internal enum SteamNetworkingConfigValue : int + { + Invalid = 0, + FakePacketLoss_Send = 2, + FakePacketLoss_Recv = 3, + FakePacketLag_Send = 4, + FakePacketLag_Recv = 5, + + FakePacketReorder_Send = 6, + FakePacketReorder_Recv = 7, + + FakePacketReorder_Time = 8, + + FakePacketDup_Send = 26, + FakePacketDup_Recv = 27, + + FakePacketDup_TimeMax = 28, + + TimeoutInitial = 24, + + TimeoutConnected = 25, + + SendBufferSize = 9, + + SendRateMin = 10, + SendRateMax = 11, + + NagleTime = 12, + + IP_AllowWithoutAuth = 23, + + SDRClient_ConsecutitivePingTimeoutsFailInitial = 19, + + SDRClient_ConsecutitivePingTimeoutsFail = 20, + + SDRClient_MinPingsBeforePingAccurate = 21, + + SDRClient_SingleSocket = 22, + + SDRClient_ForceRelayCluster = 29, + + SDRClient_DebugTicketAddress = 30, + + SDRClient_ForceProxyAddr = 31, + + LogLevel_AckRTT = 13, + LogLevel_PacketDecode = 14, + LogLevel_Message = 15, + LogLevel_PacketGaps = 16, + LogLevel_P2PRendezvous = 17, + LogLevel_SDRRelayPings = 18, + + Force32Bit = 0x7fffffff + } +} \ No newline at end of file diff --git a/Facepunch.Steamworks/Structs/SteamNetworking.cs b/Facepunch.Steamworks/Structs/SteamNetworking.cs new file mode 100644 index 0000000..7bdc3a1 --- /dev/null +++ b/Facepunch.Steamworks/Structs/SteamNetworking.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; + +namespace Steamworks.Data +{ + delegate void FSteamNetworkingSocketsDebugOutput (SteamNetworkingSocketsDebugOutputType nType, string pszMsg ); + + public struct SteamNetworkingMicroseconds + { + public long Value; + + public static implicit operator SteamNetworkingMicroseconds( long value ) + { + return new SteamNetworkingMicroseconds { Value = value }; + } + + public static implicit operator long( SteamNetworkingMicroseconds value ) + { + return value.Value; + } + + public override string ToString() => Value.ToString(); + } + + public struct SteamNetworkingPOPID + { + public uint Value; + + public static implicit operator SteamNetworkingPOPID( uint value ) + { + return new SteamNetworkingPOPID { Value = value }; + } + + public static implicit operator uint( SteamNetworkingPOPID value ) + { + return value.Value; + } + + public override string ToString() => Value.ToString(); + } + + /// + /// + /// Object that describes a "location" on the Internet with sufficient + /// detail that we can reasonably estimate an upper bound on the ping between + /// the two hosts, even if a direct route between the hosts is not possible, + /// and the connection must be routed through the Steam Datagram Relay network. + /// This does not contain any information that identifies the host. Indeed, + /// if two hosts are in the same building or otherwise have nearly identical + /// networking characteristics, then it's valid to use the same location + /// object for both of them. + /// + /// NOTE: This object should only be used in the same process! Do not serialize it, + /// send it over the wire, or persist it in a file or database! If you need + /// to do that, convert it to a string representation using the methods in + /// ISteamNetworkingUtils(). + /// + /// + public struct SteamNetworkPingLocation_t + { + [MarshalAs( UnmanagedType.ByValArray, SizeConst = 512, ArraySubType = UnmanagedType.U8 )] + public ushort[] Data; + } +} \ No newline at end of file