mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-13 15:18:07 +03:00
Adding Receive (it's crashing because it needs to be an array of intptr)
This commit is contained in:
parent
91083d5d16
commit
3b2c7a5a16
@ -99,6 +99,7 @@ namespace Steamworks
|
||||
|
||||
while ( Connected )
|
||||
{
|
||||
Receive();
|
||||
await Task.Delay( 10 );
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Steamworks.Data;
|
||||
|
||||
namespace Steamworks
|
||||
@ -64,5 +66,38 @@ namespace Steamworks
|
||||
{
|
||||
Connected = false;
|
||||
}
|
||||
|
||||
SteamNetworkingMessage_t[] messageBuffer;
|
||||
|
||||
public void Receive()
|
||||
{
|
||||
if ( messageBuffer == null )
|
||||
{
|
||||
messageBuffer = new SteamNetworkingMessage_t[128];
|
||||
}
|
||||
|
||||
var processed = SteamNetworkingSockets.Internal.ReceiveMessagesOnConnection( Connection, ref messageBuffer, messageBuffer.Length );
|
||||
|
||||
for ( int i=0; i< processed; i++ )
|
||||
{
|
||||
Console.WriteLine( "FOUND SOME!" );
|
||||
ReceiveMessage( messageBuffer[i] );
|
||||
}
|
||||
|
||||
//
|
||||
// Overwhelmed our buffer, keep going
|
||||
//
|
||||
if ( processed == messageBuffer.Length )
|
||||
Receive();
|
||||
}
|
||||
|
||||
internal unsafe void ReceiveMessage( SteamNetworkingMessage_t msg )
|
||||
{
|
||||
var stream = new UnmanagedMemoryStream( (byte*)msg.data, msg.length, msg.length, FileAccess.Read );
|
||||
|
||||
// read Message
|
||||
|
||||
msg.release.Invoke( ref msg );
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user