Connection SendMessage

This commit is contained in:
Garry Newman 2019-05-03 15:05:55 +01:00
parent 5fdbf02b29
commit 0265eda9f0

View File

@ -52,6 +52,34 @@ public string ConnectionName
set => SteamNetworkingSockets.Internal.SetConnectionName( this, value ); set => SteamNetworkingSockets.Internal.SetConnectionName( this, value );
} }
public Result SendMessage( IntPtr ptr, int size, SendType sendType = SendType.Reliable )
{
return SteamNetworkingSockets.Internal.SendMessageToConnection( this, ptr, (uint) size, (int)sendType );
}
public unsafe Result SendMessage( byte[] data, SendType sendType = SendType.Reliable )
{
fixed ( byte* ptr = data )
{
return SendMessage( (IntPtr)ptr, data.Length, sendType );
}
}
public unsafe Result SendMessage( byte[] data, int offset, int length, SendType sendType = SendType.Reliable )
{
fixed ( byte* ptr = data )
{
return SendMessage( (IntPtr)ptr + offset, length, sendType );
}
}
public unsafe Result SendMessage( string str, SendType sendType = SendType.Reliable )
{
var bytes = System.Text.Encoding.UTF8.GetBytes( str );
return SendMessage( bytes, sendType );
}
/// <summary> /// <summary>
/// Flush any messages waiting on the Nagle timer and send them at the next transmission opportunity (often that means right now). /// Flush any messages waiting on the Nagle timer and send them at the next transmission opportunity (often that means right now).
/// </summary> /// </summary>