mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-03-30 22:29:04 +03:00
Connection lanes implementation
This commit is contained in:
parent
2088f14c05
commit
f3ee5bec4e
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@ namespace Steamworks.Data
|
|||||||
public override string ToString() => Id.ToString();
|
public override string ToString() => Id.ToString();
|
||||||
public static implicit operator Connection( uint value ) => new Connection() { Id = value };
|
public static implicit operator Connection( uint value ) => new Connection() { Id = value };
|
||||||
public static implicit operator uint( Connection value ) => value.Id;
|
public static implicit operator uint( Connection value ) => value.Id;
|
||||||
public static bool operator ==( Connection value1, Connection value2 ) => value1.Equals(value2);
|
public static bool operator ==( Connection value1, Connection value2 ) => value1.Equals( value2 );
|
||||||
public static bool operator !=( Connection value1, Connection value2 ) => !value1.Equals(value2);
|
public static bool operator !=( Connection value1, Connection value2 ) => !value1.Equals( value2 );
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Accept an incoming connection that has been received on a listen socket.
|
/// Accept an incoming connection that has been received on a listen socket.
|
||||||
@ -69,30 +69,31 @@ 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 ) );
|
||||||
if ( size == 0 )
|
if ( size == 0 )
|
||||||
throw new ArgumentException( "`size` cannot be zero", nameof( size ) );
|
throw new ArgumentException( "`size` cannot be zero", nameof( size ) );
|
||||||
|
|
||||||
var copyPtr = BufferManager.Get( size, 1 );
|
var copyPtr = BufferManager.Get( size, 1 );
|
||||||
Buffer.MemoryCopy( (void*)ptr, (void*)copyPtr, size, size );
|
Buffer.MemoryCopy( (void*)ptr, (void*)copyPtr, size, size );
|
||||||
|
|
||||||
var message = SteamNetworkingUtils.AllocateMessage();
|
var message = SteamNetworkingUtils.AllocateMessage();
|
||||||
message->Connection = this;
|
message->Connection = this;
|
||||||
message->Flags = sendType;
|
message->Flags = sendType;
|
||||||
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 );
|
||||||
|
|
||||||
return messageNumber >= 0
|
return messageNumber >= 0
|
||||||
? Result.OK
|
? Result.OK
|
||||||
: (Result)(-messageNumber);
|
: (Result)(-messageNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ideally should be using an IntPtr version unless you're being really careful with the byte[] array and
|
/// Ideally should be using an IntPtr version unless you're being really careful with the byte[] array and
|
||||||
@ -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 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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__;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user