Connection lanes implementation

This commit is contained in:
André Straubmeier 2021-11-22 17:51:40 +01:00
parent 2088f14c05
commit f3ee5bec4e
4 changed files with 35 additions and 21 deletions

View File

@ -254,12 +254,12 @@ namespace Steamworks
#region FunctionMeta #region FunctionMeta
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworkingSockets_ConfigureConnectionLanes", CallingConvention = Platform.CC)] [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworkingSockets_ConfigureConnectionLanes", CallingConvention = Platform.CC)]
private static extern Result _ConfigureConnectionLanes( IntPtr self, Connection hConn, int nNumLanes, ref int pLanePriorities, ref ushort pLaneWeights ); private static extern Result _ConfigureConnectionLanes( IntPtr self, Connection hConn, int nNumLanes, [In,Out] int[] pLanePriorities, [In,Out] ushort[] pLaneWeights );
#endregion #endregion
internal Result ConfigureConnectionLanes( Connection hConn, int nNumLanes, ref int pLanePriorities, ref ushort pLaneWeights ) internal Result ConfigureConnectionLanes( Connection hConn, int nNumLanes, [In,Out] int[] pLanePriorities, [In,Out] ushort[] pLaneWeights )
{ {
var returnValue = _ConfigureConnectionLanes( Self, hConn, nNumLanes, ref pLanePriorities, ref pLaneWeights ); var returnValue = _ConfigureConnectionLanes( Self, hConn, nNumLanes, pLanePriorities, pLaneWeights );
return returnValue; return returnValue;
} }

View File

@ -69,7 +69,7 @@ namespace Steamworks.Data
/// <summary> /// <summary>
/// This is the best version to use. /// This is the best version to use.
/// </summary> /// </summary>
public unsafe Result SendMessage( IntPtr ptr, int size, SendType sendType = SendType.Reliable ) public unsafe Result SendMessage( IntPtr ptr, int size, SendType sendType = SendType.Reliable, ushort laneIndex = 0 )
{ {
if ( ptr == IntPtr.Zero ) if ( ptr == IntPtr.Zero )
throw new ArgumentNullException( nameof( ptr ) ); throw new ArgumentNullException( nameof( ptr ) );
@ -85,6 +85,7 @@ namespace Steamworks.Data
message->DataPtr = copyPtr; message->DataPtr = copyPtr;
message->DataSize = size; message->DataSize = size;
message->FreeDataPtr = BufferManager.FreeFunctionPointer; message->FreeDataPtr = BufferManager.FreeFunctionPointer;
message->IdxLane = laneIndex;
long messageNumber = 0; long messageNumber = 0;
SteamNetworkingSockets.Internal.SendMessages( 1, &message, &messageNumber ); SteamNetworkingSockets.Internal.SendMessages( 1, &message, &messageNumber );
@ -157,5 +158,14 @@ namespace Steamworks.Data
return connectionStatus; return connectionStatus;
} }
/// <summary>
/// Configure multiple outbound messages streams ("lanes") on a connection, and
/// control head-of-line blocking between them.
/// </summary>
public Result ConfigureConnectionLanes( int[] lanePriorities, ushort[] laneWeights )
{
return SteamNetworkingSockets.Internal.ConfigureConnectionLanes( this, lanePriorities.Length, lanePriorities, laneWeights );
}
} }
} }

View File

@ -18,5 +18,7 @@ namespace Steamworks.Data
internal int Channel; internal int Channel;
internal SendType Flags; internal SendType Flags;
internal long UserData; internal long UserData;
internal ushort IdxLane;
internal ushort _pad1__;
} }
} }

View File

@ -108,6 +108,8 @@ internal class BaseType
if ( VarName == "pOutMessageNumber" ) return false; if ( VarName == "pOutMessageNumber" ) return false;
if ( VarName == "pOptions" ) return true; if ( VarName == "pOptions" ) return true;
if ( VarName == "pLanes" ) return true; if ( VarName == "pLanes" ) return true;
if ( VarName == "pLanePriorities" ) return true;
if ( VarName == "pLaneWeights" ) return true;
if ( VarName == "pOut" ) return false; if ( VarName == "pOut" ) return false;
if ( VarName == "pOutBuffer" ) return false; if ( VarName == "pOutBuffer" ) return false;