mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-25 14:15:47 +03:00
Connection lanes implementation
This commit is contained in:
parent
2088f14c05
commit
f3ee5bec4e
@ -254,12 +254,12 @@ internal bool CreateSocketPair( [In,Out] Connection[] pOutConnection1, [In,Out]
|
||||
|
||||
#region FunctionMeta
|
||||
[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
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,8 @@ public struct Connection : IEquatable<Connection>
|
||||
public override string ToString() => Id.ToString();
|
||||
public static implicit operator Connection( uint value ) => new Connection() { Id = value };
|
||||
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>
|
||||
/// Accept an incoming connection that has been received on a listen socket.
|
||||
@ -69,30 +69,31 @@ public string ConnectionName
|
||||
/// <summary>
|
||||
/// This is the best version to use.
|
||||
/// </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 )
|
||||
throw new ArgumentNullException( nameof( ptr ) );
|
||||
if ( size == 0 )
|
||||
throw new ArgumentException( "`size` cannot be zero", nameof( size ) );
|
||||
if ( ptr == IntPtr.Zero )
|
||||
throw new ArgumentNullException( nameof( ptr ) );
|
||||
if ( size == 0 )
|
||||
throw new ArgumentException( "`size` cannot be zero", nameof( size ) );
|
||||
|
||||
var copyPtr = BufferManager.Get( size, 1 );
|
||||
Buffer.MemoryCopy( (void*)ptr, (void*)copyPtr, size, size );
|
||||
var copyPtr = BufferManager.Get( size, 1 );
|
||||
Buffer.MemoryCopy( (void*)ptr, (void*)copyPtr, size, size );
|
||||
|
||||
var message = SteamNetworkingUtils.AllocateMessage();
|
||||
message->Connection = this;
|
||||
message->Flags = sendType;
|
||||
message->DataPtr = copyPtr;
|
||||
var message = SteamNetworkingUtils.AllocateMessage();
|
||||
message->Connection = this;
|
||||
message->Flags = sendType;
|
||||
message->DataPtr = copyPtr;
|
||||
message->DataSize = size;
|
||||
message->FreeDataPtr = BufferManager.FreeFunctionPointer;
|
||||
message->FreeDataPtr = BufferManager.FreeFunctionPointer;
|
||||
message->IdxLane = laneIndex;
|
||||
|
||||
long messageNumber = 0;
|
||||
SteamNetworkingSockets.Internal.SendMessages( 1, &message, &messageNumber );
|
||||
|
||||
return messageNumber >= 0
|
||||
? Result.OK
|
||||
: (Result)(-messageNumber);
|
||||
}
|
||||
return messageNumber >= 0
|
||||
? Result.OK
|
||||
: (Result)(-messageNumber);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ideally should be using an IntPtr version unless you're being really careful with the byte[] array and
|
||||
@ -157,5 +158,14 @@ public ConnectionStatus QuickStatus()
|
||||
|
||||
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 @@ internal partial struct NetMsg
|
||||
internal int Channel;
|
||||
internal SendType Flags;
|
||||
internal long UserData;
|
||||
internal ushort IdxLane;
|
||||
internal ushort _pad1__;
|
||||
}
|
||||
}
|
||||
|
@ -108,6 +108,8 @@ public virtual bool IsVector
|
||||
if ( VarName == "pOutMessageNumber" ) return false;
|
||||
if ( VarName == "pOptions" ) return true;
|
||||
if ( VarName == "pLanes" ) return true;
|
||||
if ( VarName == "pLanePriorities" ) return true;
|
||||
if ( VarName == "pLaneWeights" ) return true;
|
||||
|
||||
if ( VarName == "pOut" ) return false;
|
||||
if ( VarName == "pOutBuffer" ) return false;
|
||||
|
Loading…
Reference in New Issue
Block a user