mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-26 21:48:16 +03:00
Added optional receiveToEnd toggle to ConnectionManager.Receive and SocketManager.Receive (default true = old behaviour)
This commit is contained in:
parent
b4de0927f3
commit
ea3743bd73
@ -109,7 +109,7 @@ namespace Steamworks
|
|||||||
Interface?.OnDisconnected( info );
|
Interface?.OnDisconnected( info );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Receive( int bufferSize = 32 )
|
public int Receive( int bufferSize = 32, bool receiveToEnd = true )
|
||||||
{
|
{
|
||||||
int processed = 0;
|
int processed = 0;
|
||||||
IntPtr messageBuffer = Marshal.AllocHGlobal( IntPtr.Size * bufferSize );
|
IntPtr messageBuffer = Marshal.AllocHGlobal( IntPtr.Size * bufferSize );
|
||||||
@ -131,8 +131,10 @@ namespace Steamworks
|
|||||||
//
|
//
|
||||||
// Overwhelmed our buffer, keep going
|
// Overwhelmed our buffer, keep going
|
||||||
//
|
//
|
||||||
if ( processed == bufferSize )
|
if ( receiveToEnd && processed == bufferSize )
|
||||||
Receive( bufferSize );
|
processed += Receive( bufferSize );
|
||||||
|
|
||||||
|
return processed;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal unsafe void ReceiveMessage( IntPtr msgPtr )
|
internal unsafe void ReceiveMessage( IntPtr msgPtr )
|
||||||
|
@ -123,7 +123,7 @@ namespace Steamworks
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Receive( int bufferSize = 32 )
|
public int Receive( int bufferSize = 32, bool receiveToEnd = true )
|
||||||
{
|
{
|
||||||
int processed = 0;
|
int processed = 0;
|
||||||
IntPtr messageBuffer = Marshal.AllocHGlobal( IntPtr.Size * bufferSize );
|
IntPtr messageBuffer = Marshal.AllocHGlobal( IntPtr.Size * bufferSize );
|
||||||
@ -146,8 +146,10 @@ namespace Steamworks
|
|||||||
//
|
//
|
||||||
// Overwhelmed our buffer, keep going
|
// Overwhelmed our buffer, keep going
|
||||||
//
|
//
|
||||||
if ( processed == bufferSize )
|
if ( receiveToEnd && processed == bufferSize )
|
||||||
Receive( bufferSize );
|
processed += Receive( bufferSize );
|
||||||
|
|
||||||
|
return processed;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal unsafe void ReceiveMessage( IntPtr msgPtr )
|
internal unsafe void ReceiveMessage( IntPtr msgPtr )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user