diff --git a/Facepunch.Steamworks/Networking/ConnectionManager.cs b/Facepunch.Steamworks/Networking/ConnectionManager.cs index f12fb2b..e1014f9 100644 --- a/Facepunch.Steamworks/Networking/ConnectionManager.cs +++ b/Facepunch.Steamworks/Networking/ConnectionManager.cs @@ -109,7 +109,7 @@ namespace Steamworks Interface?.OnDisconnected( info ); } - public void Receive( int bufferSize = 32 ) + public int Receive( int bufferSize = 32, bool receiveToEnd = true ) { int processed = 0; IntPtr messageBuffer = Marshal.AllocHGlobal( IntPtr.Size * bufferSize ); @@ -131,8 +131,10 @@ namespace Steamworks // // Overwhelmed our buffer, keep going // - if ( processed == bufferSize ) - Receive( bufferSize ); + if ( receiveToEnd && processed == bufferSize ) + processed += Receive( bufferSize ); + + return processed; } internal unsafe void ReceiveMessage( IntPtr msgPtr ) diff --git a/Facepunch.Steamworks/Networking/SocketManager.cs b/Facepunch.Steamworks/Networking/SocketManager.cs index b09e6be..fd7e61f 100644 --- a/Facepunch.Steamworks/Networking/SocketManager.cs +++ b/Facepunch.Steamworks/Networking/SocketManager.cs @@ -123,7 +123,7 @@ namespace Steamworks } } - public void Receive( int bufferSize = 32 ) + public int Receive( int bufferSize = 32, bool receiveToEnd = true ) { int processed = 0; IntPtr messageBuffer = Marshal.AllocHGlobal( IntPtr.Size * bufferSize ); @@ -146,8 +146,10 @@ namespace Steamworks // // Overwhelmed our buffer, keep going // - if ( processed == bufferSize ) - Receive( bufferSize ); + if ( receiveToEnd && processed == bufferSize ) + processed += Receive( bufferSize ); + + return processed; } internal unsafe void ReceiveMessage( IntPtr msgPtr )