ISteamNetworkingSockets generating

This commit is contained in:
Garry Newman 2019-05-02 16:55:50 +01:00
parent 3eae3314b6
commit 9b2ad8e49a
5 changed files with 674 additions and 0 deletions

View File

@ -101,4 +101,109 @@
Force32Bit = 0x7fffffff
}
/// High level connection status
public enum SteamNetworkingConnectionState
{
/// Dummy value used to indicate an error condition in the API.
/// Specified connection doesn't exist or has already been closed.
None = 0,
/// We are trying to establish whether peers can talk to each other,
/// whether they WANT to talk to each other, perform basic auth,
/// and exchange crypt keys.
///
/// - For connections on the "client" side (initiated locally):
/// We're in the process of trying to establish a connection.
/// Depending on the connection type, we might not know who they are.
/// Note that it is not possible to tell if we are waiting on the
/// network to complete handshake packets, or for the application layer
/// to accept the connection.
///
/// - For connections on the "server" side (accepted through listen socket):
/// We have completed some basic handshake and the client has presented
/// some proof of identity. The connection is ready to be accepted
/// using AcceptConnection().
///
/// In either case, any unreliable packets sent now are almost certain
/// to be dropped. Attempts to receive packets are guaranteed to fail.
/// You may send messages if the send mode allows for them to be queued.
/// but if you close the connection before the connection is actually
/// established, any queued messages will be discarded immediately.
/// (We will not attempt to flush the queue and confirm delivery to the
/// remote host, which ordinarily happens when a connection is closed.)
Connecting = 1,
/// Some connection types use a back channel or trusted 3rd party
/// for earliest communication. If the server accepts the connection,
/// then these connections switch into the rendezvous state. During this
/// state, we still have not yet established an end-to-end route (through
/// the relay network), and so if you send any messages unreliable, they
/// are going to be discarded.
FindingRoute = 2,
/// We've received communications from our peer (and we know
/// who they are) and are all good. If you close the connection now,
/// we will make our best effort to flush out any reliable sent data that
/// has not been acknowledged by the peer. (But note that this happens
/// from within the application process, so unlike a TCP connection, you are
/// not totally handing it off to the operating system to deal with it.)
Connected = 3,
/// Connection has been closed by our peer, but not closed locally.
/// The connection still exists from an API perspective. You must close the
/// handle to free up resources. If there are any messages in the inbound queue,
/// you may retrieve them. Otherwise, nothing may be done with the connection
/// except to close it.
///
/// This stats is similar to CLOSE_WAIT in the TCP state machine.
ClosedByPeer = 4,
/// A disruption in the connection has been detected locally. (E.g. timeout,
/// local internet connection disrupted, etc.)
///
/// The connection still exists from an API perspective. You must close the
/// handle to free up resources.
///
/// Attempts to send further messages will fail. Any remaining received messages
/// in the queue are available.
ProblemDetectedLocally = 5,
//
// The following values are used internally and will not be returned by any API.
// We document them here to provide a little insight into the state machine that is used
// under the hood.
//
/// We've disconnected on our side, and from an API perspective the connection is closed.
/// No more data may be sent or received. All reliable data has been flushed, or else
/// we've given up and discarded it. We do not yet know for sure that the peer knows
/// the connection has been closed, however, so we're just hanging around so that if we do
/// get a packet from them, we can send them the appropriate packets so that they can
/// know why the connection was closed (and not have to rely on a timeout, which makes
/// it appear as if something is wrong).
FinWait = -1,
/// We've disconnected on our side, and from an API perspective the connection is closed.
/// No more data may be sent or received. From a network perspective, however, on the wire,
/// we have not yet given any indication to the peer that the connection is closed.
/// We are in the process of flushing out the last bit of reliable data. Once that is done,
/// we will inform the peer that the connection has been closed, and transition to the
/// FinWait state.
///
/// Note that no indication is given to the remote host that we have closed the connection,
/// until the data has been flushed. If the remote host attempts to send us data, we will
/// do whatever is necessary to keep the connection alive until it can be closed properly.
/// But in fact the data will be discarded, since there is no way for the application to
/// read it back. Typically this is not a problem, as application protocols that utilize
/// the lingering functionality are designed for the remote host to wait for the response
/// before sending any more data.
Linger = -2,
/// Connection is completely inactive and ready to be destroyed
Dead = -3,
Force32Bit = 0x7fffffff
};
}

View File

@ -0,0 +1,378 @@
using System;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using Steamworks.Data;
namespace Steamworks
{
internal class ISteamNetworkingSockets : SteamInterface
{
public override string InterfaceName => "SteamNetworkingSockets002";
public override void InitInternals()
{
_CreateListenSocketIP = Marshal.GetDelegateForFunctionPointer<FCreateListenSocketIP>( Marshal.ReadIntPtr( VTable, 0) );
_ConnectByIPAddress = Marshal.GetDelegateForFunctionPointer<FConnectByIPAddress>( Marshal.ReadIntPtr( VTable, 8) );
_CreateListenSocketP2P = Marshal.GetDelegateForFunctionPointer<FCreateListenSocketP2P>( Marshal.ReadIntPtr( VTable, 16) );
_ConnectP2P = Marshal.GetDelegateForFunctionPointer<FConnectP2P>( Marshal.ReadIntPtr( VTable, 24) );
_AcceptConnection = Marshal.GetDelegateForFunctionPointer<FAcceptConnection>( Marshal.ReadIntPtr( VTable, 32) );
_CloseConnection = Marshal.GetDelegateForFunctionPointer<FCloseConnection>( Marshal.ReadIntPtr( VTable, 40) );
_CloseListenSocket = Marshal.GetDelegateForFunctionPointer<FCloseListenSocket>( Marshal.ReadIntPtr( VTable, 48) );
_SetConnectionUserData = Marshal.GetDelegateForFunctionPointer<FSetConnectionUserData>( Marshal.ReadIntPtr( VTable, 56) );
_GetConnectionUserData = Marshal.GetDelegateForFunctionPointer<FGetConnectionUserData>( Marshal.ReadIntPtr( VTable, 64) );
_SetConnectionName = Marshal.GetDelegateForFunctionPointer<FSetConnectionName>( Marshal.ReadIntPtr( VTable, 72) );
_GetConnectionName = Marshal.GetDelegateForFunctionPointer<FGetConnectionName>( Marshal.ReadIntPtr( VTable, 80) );
_SendMessageToConnection = Marshal.GetDelegateForFunctionPointer<FSendMessageToConnection>( Marshal.ReadIntPtr( VTable, 88) );
_FlushMessagesOnConnection = Marshal.GetDelegateForFunctionPointer<FFlushMessagesOnConnection>( Marshal.ReadIntPtr( VTable, 96) );
_ReceiveMessagesOnConnection = Marshal.GetDelegateForFunctionPointer<FReceiveMessagesOnConnection>( Marshal.ReadIntPtr( VTable, 104) );
_ReceiveMessagesOnListenSocket = Marshal.GetDelegateForFunctionPointer<FReceiveMessagesOnListenSocket>( Marshal.ReadIntPtr( VTable, 112) );
_GetConnectionInfo = Marshal.GetDelegateForFunctionPointer<FGetConnectionInfo>( Marshal.ReadIntPtr( VTable, 120) );
_GetQuickConnectionStatus = Marshal.GetDelegateForFunctionPointer<FGetQuickConnectionStatus>( Marshal.ReadIntPtr( VTable, 128) );
_GetDetailedConnectionStatus = Marshal.GetDelegateForFunctionPointer<FGetDetailedConnectionStatus>( Marshal.ReadIntPtr( VTable, 136) );
_GetListenSocketAddress = Marshal.GetDelegateForFunctionPointer<FGetListenSocketAddress>( Marshal.ReadIntPtr( VTable, 144) );
_CreateSocketPair = Marshal.GetDelegateForFunctionPointer<FCreateSocketPair>( Marshal.ReadIntPtr( VTable, 152) );
_GetIdentity = Marshal.GetDelegateForFunctionPointer<FGetIdentity>( Marshal.ReadIntPtr( VTable, 160) );
_ReceivedRelayAuthTicket = Marshal.GetDelegateForFunctionPointer<FReceivedRelayAuthTicket>( Marshal.ReadIntPtr( VTable, 168) );
_FindRelayAuthTicketForServer = Marshal.GetDelegateForFunctionPointer<FFindRelayAuthTicketForServer>( Marshal.ReadIntPtr( VTable, 176) );
_ConnectToHostedDedicatedServer = Marshal.GetDelegateForFunctionPointer<FConnectToHostedDedicatedServer>( Marshal.ReadIntPtr( VTable, 184) );
_GetHostedDedicatedServerPort = Marshal.GetDelegateForFunctionPointer<FGetHostedDedicatedServerPort>( Marshal.ReadIntPtr( VTable, 192) );
_GetHostedDedicatedServerPOPID = Marshal.GetDelegateForFunctionPointer<FGetHostedDedicatedServerPOPID>( Marshal.ReadIntPtr( VTable, 200) );
_GetHostedDedicatedServerAddress = Marshal.GetDelegateForFunctionPointer<FGetHostedDedicatedServerAddress>( Marshal.ReadIntPtr( VTable, 208) );
_CreateHostedDedicatedServerListenSocket = Marshal.GetDelegateForFunctionPointer<FCreateHostedDedicatedServerListenSocket>( Marshal.ReadIntPtr( VTable, 216) );
_RunCallbacks = Marshal.GetDelegateForFunctionPointer<FRunCallbacks>( Marshal.ReadIntPtr( VTable, 224) );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
private delegate HSteamListenSocket FCreateListenSocketIP( IntPtr self, ref SteamNetworkingIPAddr localAddress );
private FCreateListenSocketIP _CreateListenSocketIP;
#endregion
internal HSteamListenSocket CreateListenSocketIP( ref SteamNetworkingIPAddr localAddress )
{
return _CreateListenSocketIP( Self, ref localAddress );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
private delegate HSteamNetConnection FConnectByIPAddress( IntPtr self, ref SteamNetworkingIPAddr address );
private FConnectByIPAddress _ConnectByIPAddress;
#endregion
internal HSteamNetConnection ConnectByIPAddress( ref SteamNetworkingIPAddr address )
{
return _ConnectByIPAddress( Self, ref address );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
private delegate HSteamListenSocket FCreateListenSocketP2P( IntPtr self, int nVirtualPort );
private FCreateListenSocketP2P _CreateListenSocketP2P;
#endregion
internal HSteamListenSocket CreateListenSocketP2P( int nVirtualPort )
{
return _CreateListenSocketP2P( Self, nVirtualPort );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
private delegate HSteamNetConnection FConnectP2P( IntPtr self, ref SteamNetworkingIdentity identityRemote, int nVirtualPort );
private FConnectP2P _ConnectP2P;
#endregion
internal HSteamNetConnection ConnectP2P( ref SteamNetworkingIdentity identityRemote, int nVirtualPort )
{
return _ConnectP2P( Self, ref identityRemote, nVirtualPort );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
private delegate Result FAcceptConnection( IntPtr self, HSteamNetConnection hConn );
private FAcceptConnection _AcceptConnection;
#endregion
internal Result AcceptConnection( HSteamNetConnection hConn )
{
return _AcceptConnection( Self, hConn );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
[return: MarshalAs( UnmanagedType.I1 )]
private delegate bool FCloseConnection( IntPtr self, HSteamNetConnection hPeer, int nReason, string pszDebug, [MarshalAs( UnmanagedType.U1 )] bool bEnableLinger );
private FCloseConnection _CloseConnection;
#endregion
internal bool CloseConnection( HSteamNetConnection hPeer, int nReason, string pszDebug, [MarshalAs( UnmanagedType.U1 )] bool bEnableLinger )
{
return _CloseConnection( Self, hPeer, nReason, pszDebug, bEnableLinger );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
[return: MarshalAs( UnmanagedType.I1 )]
private delegate bool FCloseListenSocket( IntPtr self, HSteamListenSocket hSocket );
private FCloseListenSocket _CloseListenSocket;
#endregion
internal bool CloseListenSocket( HSteamListenSocket hSocket )
{
return _CloseListenSocket( Self, hSocket );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
[return: MarshalAs( UnmanagedType.I1 )]
private delegate bool FSetConnectionUserData( IntPtr self, HSteamNetConnection hPeer, long nUserData );
private FSetConnectionUserData _SetConnectionUserData;
#endregion
internal bool SetConnectionUserData( HSteamNetConnection hPeer, long nUserData )
{
return _SetConnectionUserData( Self, hPeer, nUserData );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
private delegate long FGetConnectionUserData( IntPtr self, HSteamNetConnection hPeer );
private FGetConnectionUserData _GetConnectionUserData;
#endregion
internal long GetConnectionUserData( HSteamNetConnection hPeer )
{
return _GetConnectionUserData( Self, hPeer );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
private delegate void FSetConnectionName( IntPtr self, HSteamNetConnection hPeer, string pszName );
private FSetConnectionName _SetConnectionName;
#endregion
internal void SetConnectionName( HSteamNetConnection hPeer, string pszName )
{
_SetConnectionName( Self, hPeer, pszName );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
[return: MarshalAs( UnmanagedType.I1 )]
private delegate bool FGetConnectionName( IntPtr self, HSteamNetConnection hPeer, StringBuilder pszName, int nMaxLen );
private FGetConnectionName _GetConnectionName;
#endregion
internal bool GetConnectionName( HSteamNetConnection hPeer, StringBuilder pszName, int nMaxLen )
{
return _GetConnectionName( Self, hPeer, pszName, nMaxLen );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
private delegate Result FSendMessageToConnection( IntPtr self, HSteamNetConnection hConn, IntPtr pData, uint cbData, int nSendFlags );
private FSendMessageToConnection _SendMessageToConnection;
#endregion
internal Result SendMessageToConnection( HSteamNetConnection hConn, IntPtr pData, uint cbData, int nSendFlags )
{
return _SendMessageToConnection( Self, hConn, pData, cbData, nSendFlags );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
private delegate Result FFlushMessagesOnConnection( IntPtr self, HSteamNetConnection hConn );
private FFlushMessagesOnConnection _FlushMessagesOnConnection;
#endregion
internal Result FlushMessagesOnConnection( HSteamNetConnection hConn )
{
return _FlushMessagesOnConnection( Self, hConn );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
private delegate int FReceiveMessagesOnConnection( IntPtr self, HSteamNetConnection hConn, [In,Out] ref SteamNetworkingMessage_t[] ppOutMessages, int nMaxMessages );
private FReceiveMessagesOnConnection _ReceiveMessagesOnConnection;
#endregion
internal int ReceiveMessagesOnConnection( HSteamNetConnection hConn, [In,Out] ref SteamNetworkingMessage_t[] ppOutMessages, int nMaxMessages )
{
return _ReceiveMessagesOnConnection( Self, hConn, ref ppOutMessages, nMaxMessages );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
private delegate int FReceiveMessagesOnListenSocket( IntPtr self, HSteamListenSocket hSocket, [In,Out] ref SteamNetworkingMessage_t[] ppOutMessages, int nMaxMessages );
private FReceiveMessagesOnListenSocket _ReceiveMessagesOnListenSocket;
#endregion
internal int ReceiveMessagesOnListenSocket( HSteamListenSocket hSocket, [In,Out] ref SteamNetworkingMessage_t[] ppOutMessages, int nMaxMessages )
{
return _ReceiveMessagesOnListenSocket( Self, hSocket, ref ppOutMessages, nMaxMessages );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
[return: MarshalAs( UnmanagedType.I1 )]
private delegate bool FGetConnectionInfo( IntPtr self, HSteamNetConnection hConn, ref SteamNetConnectionInfo_t pInfo );
private FGetConnectionInfo _GetConnectionInfo;
#endregion
internal bool GetConnectionInfo( HSteamNetConnection hConn, ref SteamNetConnectionInfo_t pInfo )
{
return _GetConnectionInfo( Self, hConn, ref pInfo );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
[return: MarshalAs( UnmanagedType.I1 )]
private delegate bool FGetQuickConnectionStatus( IntPtr self, HSteamNetConnection hConn, ref SteamNetworkingQuickConnectionStatus pStats );
private FGetQuickConnectionStatus _GetQuickConnectionStatus;
#endregion
internal bool GetQuickConnectionStatus( HSteamNetConnection hConn, ref SteamNetworkingQuickConnectionStatus pStats )
{
return _GetQuickConnectionStatus( Self, hConn, ref pStats );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
private delegate int FGetDetailedConnectionStatus( IntPtr self, HSteamNetConnection hConn, StringBuilder pszBuf, int cbBuf );
private FGetDetailedConnectionStatus _GetDetailedConnectionStatus;
#endregion
internal int GetDetailedConnectionStatus( HSteamNetConnection hConn, StringBuilder pszBuf, int cbBuf )
{
return _GetDetailedConnectionStatus( Self, hConn, pszBuf, cbBuf );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
[return: MarshalAs( UnmanagedType.I1 )]
private delegate bool FGetListenSocketAddress( IntPtr self, HSteamListenSocket hSocket, ref SteamNetworkingIPAddr address );
private FGetListenSocketAddress _GetListenSocketAddress;
#endregion
internal bool GetListenSocketAddress( HSteamListenSocket hSocket, ref SteamNetworkingIPAddr address )
{
return _GetListenSocketAddress( Self, hSocket, ref address );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
[return: MarshalAs( UnmanagedType.I1 )]
private delegate bool FCreateSocketPair( IntPtr self, [In,Out] HSteamNetConnection[] pOutConnection1, [In,Out] HSteamNetConnection[] pOutConnection2, [MarshalAs( UnmanagedType.U1 )] bool bUseNetworkLoopback, ref SteamNetworkingIdentity pIdentity1, ref SteamNetworkingIdentity pIdentity2 );
private FCreateSocketPair _CreateSocketPair;
#endregion
internal bool CreateSocketPair( [In,Out] HSteamNetConnection[] pOutConnection1, [In,Out] HSteamNetConnection[] pOutConnection2, [MarshalAs( UnmanagedType.U1 )] bool bUseNetworkLoopback, ref SteamNetworkingIdentity pIdentity1, ref SteamNetworkingIdentity pIdentity2 )
{
return _CreateSocketPair( Self, pOutConnection1, pOutConnection2, bUseNetworkLoopback, ref pIdentity1, ref pIdentity2 );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
[return: MarshalAs( UnmanagedType.I1 )]
private delegate bool FGetIdentity( IntPtr self, ref SteamNetworkingIdentity pIdentity );
private FGetIdentity _GetIdentity;
#endregion
internal bool GetIdentity( ref SteamNetworkingIdentity pIdentity )
{
return _GetIdentity( Self, ref pIdentity );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
[return: MarshalAs( UnmanagedType.I1 )]
private delegate bool FReceivedRelayAuthTicket( IntPtr self, IntPtr pvTicket, int cbTicket, [In,Out] SteamDatagramRelayAuthTicket[] pOutParsedTicket );
private FReceivedRelayAuthTicket _ReceivedRelayAuthTicket;
#endregion
internal bool ReceivedRelayAuthTicket( IntPtr pvTicket, int cbTicket, [In,Out] SteamDatagramRelayAuthTicket[] pOutParsedTicket )
{
return _ReceivedRelayAuthTicket( Self, pvTicket, cbTicket, pOutParsedTicket );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
private delegate int FFindRelayAuthTicketForServer( IntPtr self, ref SteamNetworkingIdentity identityGameServer, int nVirtualPort, [In,Out] SteamDatagramRelayAuthTicket[] pOutParsedTicket );
private FFindRelayAuthTicketForServer _FindRelayAuthTicketForServer;
#endregion
internal int FindRelayAuthTicketForServer( ref SteamNetworkingIdentity identityGameServer, int nVirtualPort, [In,Out] SteamDatagramRelayAuthTicket[] pOutParsedTicket )
{
return _FindRelayAuthTicketForServer( Self, ref identityGameServer, nVirtualPort, pOutParsedTicket );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
private delegate HSteamNetConnection FConnectToHostedDedicatedServer( IntPtr self, ref SteamNetworkingIdentity identityTarget, int nVirtualPort );
private FConnectToHostedDedicatedServer _ConnectToHostedDedicatedServer;
#endregion
internal HSteamNetConnection ConnectToHostedDedicatedServer( ref SteamNetworkingIdentity identityTarget, int nVirtualPort )
{
return _ConnectToHostedDedicatedServer( Self, ref identityTarget, nVirtualPort );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
private delegate ushort FGetHostedDedicatedServerPort( IntPtr self );
private FGetHostedDedicatedServerPort _GetHostedDedicatedServerPort;
#endregion
internal ushort GetHostedDedicatedServerPort()
{
return _GetHostedDedicatedServerPort( Self );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
private delegate SteamNetworkingPOPID FGetHostedDedicatedServerPOPID( IntPtr self );
private FGetHostedDedicatedServerPOPID _GetHostedDedicatedServerPOPID;
#endregion
internal SteamNetworkingPOPID GetHostedDedicatedServerPOPID()
{
return _GetHostedDedicatedServerPOPID( Self );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
[return: MarshalAs( UnmanagedType.I1 )]
private delegate bool FGetHostedDedicatedServerAddress( IntPtr self, ref SteamDatagramHostedAddress pRouting );
private FGetHostedDedicatedServerAddress _GetHostedDedicatedServerAddress;
#endregion
internal bool GetHostedDedicatedServerAddress( ref SteamDatagramHostedAddress pRouting )
{
return _GetHostedDedicatedServerAddress( Self, ref pRouting );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
private delegate HSteamListenSocket FCreateHostedDedicatedServerListenSocket( IntPtr self, int nVirtualPort );
private FCreateHostedDedicatedServerListenSocket _CreateHostedDedicatedServerListenSocket;
#endregion
internal HSteamListenSocket CreateHostedDedicatedServerListenSocket( int nVirtualPort )
{
return _CreateHostedDedicatedServerListenSocket( Self, nVirtualPort );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
private delegate void FRunCallbacks( IntPtr self, IntPtr pCallbacks );
private FRunCallbacks _RunCallbacks;
#endregion
internal void RunCallbacks( IntPtr pCallbacks )
{
_RunCallbacks( Self, pCallbacks );
}
}
}

View File

@ -41,6 +41,163 @@ namespace Steamworks.Data
public override string ToString() => Value.ToString();
}
public struct HSteamListenSocket
{
public uint Value;
public static implicit operator HSteamListenSocket( uint value )
{
return new HSteamListenSocket { Value = value };
}
public static implicit operator uint( HSteamListenSocket value )
{
return value.Value;
}
public override string ToString() => Value.ToString();
}
public struct HSteamNetConnection
{
public uint Value;
public static implicit operator HSteamNetConnection( uint value )
{
return new HSteamNetConnection { Value = value };
}
public static implicit operator uint( HSteamNetConnection value )
{
return value.Value;
}
public override string ToString() => Value.ToString();
}
public enum IdentityType
{
Invalid = 0,
IPAddress = 1,
GenericString = 2,
GenericBytes = 3,
SteamID = 16
}
[StructLayout( LayoutKind.Explicit, Size = 136 )]
public struct SteamNetworkingIdentity
{
[FieldOffset( 0 )]
public IdentityType type;
/*
public bool IsInvalid
{
get
{
return Native.SteamAPI_SteamNetworkingIdentity_IsInvalid( this );
}
}
public ulong GetSteamID()
{
return Native.SteamAPI_SteamNetworkingIdentity_GetSteamID64( this );
}
public void SetSteamID( ulong steamID )
{
Native.SteamAPI_SteamNetworkingIdentity_SetSteamID64( ref this, steamID );
}
public bool EqualsTo( NetworkingIdentity identity )
{
return Native.SteamAPI_SteamNetworkingIdentity_EqualTo( this, identity );
}*/
}
[StructLayout( LayoutKind.Sequential )]
public struct SteamNetworkingIPAddr
{
[MarshalAs( UnmanagedType.ByValArray, SizeConst = 16 )]
public byte[] ip;
public ushort port;
/*
public bool IsLocalHost
{
get
{
return Native.SteamAPI_SteamNetworkingIPAddr_IsLocalHost( ref this );
}
}
public string GetIP()
{
return ip.ParseIP();
}
public void SetLocalHost( ushort port )
{
Native.SteamAPI_SteamNetworkingIPAddr_SetIPv6LocalHost( ref this, port );
}
public void SetAddress( string ip, ushort port )
{
if ( !ip.Contains( ":" ) )
Native.SteamAPI_SteamNetworkingIPAddr_SetIPv4( ref this, ip.ParseIPv4(), port );
else
Native.SteamAPI_SteamNetworkingIPAddr_SetIPv6( ref this, ip.ParseIPv6(), port );
}*/
}
[StructLayout( LayoutKind.Sequential )]
public struct SteamNetworkingMessage_t
{
public IntPtr data;
public int length;
public HSteamNetConnection connection;
public SteamNetworkingIdentity identity;
public long userData;
public SteamNetworkingMicroseconds timeReceived;
public long messageNumber;
internal IntPtr release;
public int channel;
private int pad;
/*
public void CopyTo( byte[] destination )
{
if ( destination == null )
throw new ArgumentNullException( "destination" );
Marshal.Copy( data, destination, 0, length );
}
public void Destroy()
{
if ( release == IntPtr.Zero )
throw new InvalidOperationException( "Message not created" );
Native.SteamAPI_SteamNetworkingMessage_t_Release( release );
}*/
}
[StructLayout( LayoutKind.Sequential )]
public struct SteamNetConnectionInfo_t
{
public SteamNetworkingIdentity identity;
public long userData;
public HSteamListenSocket listenSocket;
public SteamNetworkingIPAddr address;
private ushort pad;
private SteamNetworkingPOPID popRemote;
private SteamNetworkingPOPID popRelay;
public SteamNetworkingConnectionState state;
public int endReason;
[MarshalAs( UnmanagedType.ByValTStr, SizeConst = 128 )]
public string endDebug;
[MarshalAs( UnmanagedType.ByValTStr, SizeConst = 128 )]
public string connectionDescription;
}
/// <summary>
///
/// Object that describes a "location" on the Internet with sufficient
@ -108,4 +265,35 @@ namespace Steamworks.Data
return SteamNetworkingUtils.Internal.EstimatePingTimeBetweenTwoLocations( ref this, ref target );
}
}
[StructLayout( LayoutKind.Sequential )]
public struct SteamNetworkingQuickConnectionStatus
{
public SteamNetworkingConnectionState 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 SteamNetworkingMicroseconds queueTime;
[MarshalAs( UnmanagedType.ByValArray, SizeConst = 16 )]
uint[] reserved;
}
struct SteamDatagramRelayAuthTicket
{
// Not implemented
};
struct SteamDatagramHostedAddress
{
// Not implemented
}
}

View File

@ -81,6 +81,7 @@ namespace Generator
GenerateVTableClass( "ISteamMatchmaking", $"{folder}../Generated/Interfaces/ISteamMatchmaking.cs" );
GenerateVTableClass( "ISteamParties", $"{folder}../Generated/Interfaces/ISteamParties.cs" );
GenerateVTableClass( "ISteamNetworkingUtils", $"{folder}../Generated/Interfaces/ISteamNetworkingUtils.cs" );
GenerateVTableClass( "ISteamNetworkingSockets", $"{folder}../Generated/Interfaces/ISteamNetworkingSockets.cs" );
}
}

View File

@ -49,6 +49,8 @@ internal class BaseType
if ( basicType == "InventoryItemId" ) return new StructType { NativeType = type, VarName = varname, StructName = basicType };
if ( basicType == "InventoryDefId" ) return new StructType { NativeType = type, VarName = varname, StructName = basicType };
if ( basicType == "PingLocation" ) return new StructType { NativeType = type, VarName = varname, StructName = basicType };
if ( basicType == "SteamNetworkingIPAddr" ) return new StructType { NativeType = type, VarName = varname, StructName = basicType };
if ( basicType == "SteamNetworkingIdentity" ) return new StructType { NativeType = type, VarName = varname, StructName = basicType };
if ( basicType.StartsWith( "E" ) && char.IsUpper( basicType[1] ) ) return new EnumType { NativeType = type.Substring( 1 ), VarName = varname };
return new BaseType { NativeType = type, VarName = varname };