diff --git a/Facepunch.Steamworks/Structs/NetConnection.cs b/Facepunch.Steamworks/Structs/NetConnection.cs index 9f5afa1..a01cf4a 100644 --- a/Facepunch.Steamworks/Structs/NetConnection.cs +++ b/Facepunch.Steamworks/Structs/NetConnection.cs @@ -52,6 +52,34 @@ public string ConnectionName 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 ); + } + /// /// Flush any messages waiting on the Nagle timer and send them at the next transmission opportunity (often that means right now). ///