mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-26 22:55:55 +03:00
Make SendMessage call SendMessages instead of SendMessageToConnection
This commit is contained in:
parent
28effd140b
commit
5c11508f41
@ -65,10 +65,29 @@ public string ConnectionName
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is the best version to use.
|
/// This is the best version to use.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Result SendMessage( IntPtr ptr, int size, SendType sendType = SendType.Reliable )
|
public unsafe Result SendMessage( IntPtr ptr, int size, SendType sendType = SendType.Reliable )
|
||||||
{
|
{
|
||||||
|
if ( ptr == IntPtr.Zero )
|
||||||
|
throw new ArgumentNullException( nameof( ptr ) );
|
||||||
|
if ( size == 0 )
|
||||||
|
throw new ArgumentException( "`size` cannot be zero", nameof( size ) );
|
||||||
|
|
||||||
|
var copyPtr = BroadcastBufferManager.Get( size, 1 );
|
||||||
|
Buffer.MemoryCopy( (void*)ptr, (void*)copyPtr, size, size );
|
||||||
|
|
||||||
|
var message = SteamNetworkingUtils.AllocateMessage();
|
||||||
|
message->Connection = this;
|
||||||
|
message->Flags = sendType;
|
||||||
|
message->DataPtr = copyPtr;
|
||||||
|
message->DataSize = size;
|
||||||
|
message->FreeDataPtr = BroadcastBufferManager.FreeFunctionPointer;
|
||||||
|
|
||||||
long messageNumber = 0;
|
long messageNumber = 0;
|
||||||
return SteamNetworkingSockets.Internal.SendMessageToConnection( this, ptr, (uint) size, (int)sendType, ref messageNumber );
|
SteamNetworkingSockets.Internal.SendMessages( 1, &message, &messageNumber );
|
||||||
|
|
||||||
|
return messageNumber >= 0
|
||||||
|
? Result.OK
|
||||||
|
: (Result)(-messageNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user