From 27a0048c0e66749fc4217455ca7613e74b53d813 Mon Sep 17 00:00:00 2001 From: james7132 Date: Sat, 16 Jan 2021 20:08:11 -0800 Subject: [PATCH] Fix #523: Make Lobby.SendChatBytes public. Also add a unsafe variant that would require zero copies to a managed array. --- Facepunch.Steamworks/Structs/Lobby.cs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Facepunch.Steamworks/Structs/Lobby.cs b/Facepunch.Steamworks/Structs/Lobby.cs index b944499..506fc6c 100644 --- a/Facepunch.Steamworks/Structs/Lobby.cs +++ b/Facepunch.Steamworks/Structs/Lobby.cs @@ -140,17 +140,23 @@ namespace Steamworks.Data /// /// Sends bytes the the chat room - /// this isn't exposed because there's no way to read raw bytes atm, - /// and I figure people can send json if they want something more advanced /// - internal unsafe bool SendChatBytes( byte[] data ) + public unsafe bool SendChatBytes( byte[] data ) { fixed ( byte* ptr = data ) { - return SteamMatchmaking.Internal.SendLobbyChatMsg( Id, (IntPtr)ptr, data.Length ); + return SendChatBytesUnsafe( ptr, data.Length ); } } + /// + /// Sends bytes the the chat room from a unsafe buffer + /// + public unsafe bool SendChatBytesUnsafe( byte* ptr, int length ) + { + return SteamMatchmaking.Internal.SendLobbyChatMsg( Id, (IntPtr)ptr, length ); + } + /// /// Refreshes metadata for a lobby you're not necessarily in right now /// you never do this for lobbies you're a member of, only if your @@ -202,7 +208,7 @@ namespace Steamworks.Data /// /// [SteamID variant] - /// Allows the owner to set the game server associated with the lobby. Triggers the + /// Allows the owner to set the game server associated with the lobby. Triggers the /// Steammatchmaking.OnLobbyGameCreated event. /// public void SetGameServer( SteamId steamServer ) @@ -215,7 +221,7 @@ namespace Steamworks.Data /// /// [IP/Port variant] - /// Allows the owner to set the game server associated with the lobby. Triggers the + /// Allows the owner to set the game server associated with the lobby. Triggers the /// Steammatchmaking.OnLobbyGameCreated event. /// public void SetGameServer( string ip, ushort port ) @@ -227,7 +233,7 @@ namespace Steamworks.Data } /// - /// Gets the details of the lobby's game server, if set. Returns true if the lobby is + /// Gets the details of the lobby's game server, if set. Returns true if the lobby is /// valid and has a server set, otherwise returns false. /// public bool GetGameServer( ref uint ip, ref ushort port, ref SteamId serverId ) @@ -249,4 +255,4 @@ namespace Steamworks.Data /// public bool IsOwnedBy( SteamId k ) => Owner.Id == k; } -} \ No newline at end of file +}