From e5b467ae350be8f0da96acaf70a8fbbfb9276668 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Thu, 27 Feb 2020 20:00:38 +0000 Subject: [PATCH] SendMessage comments --- Facepunch.Steamworks/Networking/Connection.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Facepunch.Steamworks/Networking/Connection.cs b/Facepunch.Steamworks/Networking/Connection.cs index 147d37e..f5f75e5 100644 --- a/Facepunch.Steamworks/Networking/Connection.cs +++ b/Facepunch.Steamworks/Networking/Connection.cs @@ -61,13 +61,19 @@ namespace Steamworks.Data set => SteamNetworkingSockets.Internal.SetConnectionName( this, value ); } - + /// + /// This is the best version to use. + /// public Result SendMessage( IntPtr ptr, int size, SendType sendType = SendType.Reliable ) { long messageNumber = 0; return SteamNetworkingSockets.Internal.SendMessageToConnection( this, ptr, (uint) size, (int)sendType, ref messageNumber ); } + /// + /// Ideally should be using an IntPtr version unless you're being really careful with the byte[] array and + /// you're not creating a new one every frame (like using .ToArray()) + /// public unsafe Result SendMessage( byte[] data, SendType sendType = SendType.Reliable ) { fixed ( byte* ptr = data ) @@ -76,6 +82,10 @@ namespace Steamworks.Data } } + /// + /// Ideally should be using an IntPtr version unless you're being really careful with the byte[] array and + /// you're not creating a new one every frame (like using .ToArray()) + /// public unsafe Result SendMessage( byte[] data, int offset, int length, SendType sendType = SendType.Reliable ) { fixed ( byte* ptr = data ) @@ -84,6 +94,9 @@ namespace Steamworks.Data } } + /// + /// This creates a ton of garbage - so don't do anything with this beyond testing! + /// public unsafe Result SendMessage( string str, SendType sendType = SendType.Reliable ) { var bytes = System.Text.Encoding.UTF8.GetBytes( str );