NetMsg with Release

This commit is contained in:
Garry Newman 2019-05-06 12:02:09 +01:00
parent 12ab3f1248
commit 14d947c7ba
2 changed files with 35 additions and 31 deletions

View File

@ -0,0 +1,35 @@
using Steamworks.Data;
using System;
using System.Runtime.InteropServices;
namespace Steamworks.Data
{
[StructLayout( LayoutKind.Sequential )]
internal struct NetMsg
{
// #32bit
internal IntPtr DataPtr;
internal int DataSize;
internal NetConnection Connection;
internal NetworkIdentity Identity;
internal long ConnectionUserData;
internal SteamNetworkingMicroseconds TimeRecv;
internal long MessageNumber;
internal IntPtr FreeDataPtr;
internal IntPtr ReleasePtr;
internal int Channel;
internal delegate void ReleaseDelegate( IntPtr msg );
public void Release( IntPtr data )
{
//
// I think this function might be a static global, so we could probably
// cache this release call.
//
var d = Marshal.GetDelegateForFunctionPointer<ReleaseDelegate>( ReleasePtr );
d( data );
}
}
}

View File

@ -41,37 +41,6 @@ public static implicit operator uint( SteamNetworkingPOPID value )
public override string ToString() => Value.ToString();
}
[StructLayout( LayoutKind.Sequential )]
public struct SteamNetworkingMessage_t
{
public IntPtr data;
public int length;
public NetConnection connection;
public NetworkIdentity 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 SteamNetworkingQuickConnectionStatus
{