From 0265eda9f0d39dff95248efcef9251413f975947 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Fri, 3 May 2019 15:05:55 +0100 Subject: [PATCH] Connection SendMessage --- Facepunch.Steamworks/Structs/NetConnection.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) 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 @@ namespace Steamworks.Data 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). ///