RustCSharpInterop/FfiChannels/Program.cs
2023-10-17 19:00:03 +02:00

25 lines
810 B
C#

using FfiChannels;
Bindings.register_callback((bytes) => {
var data = bytes.ToByteArray();
Console.WriteLine($"Callback called, bytes: {string.Join(',',data)}");
});
Bindings.start_listening();
Console.WriteLine("Press key to send");
Console.ReadKey(true);
Bindings.send(new byte[]{ 1,2,3,4,5,6,7,8,9,10 }, 10);
Console.WriteLine("Press key to exit");
Console.ReadKey(true);
// var receiving = Bindings.ReceiveAsync();
// Console.WriteLine("Press key to send");
// Console.ReadKey(true);
// Console.WriteLine("Hello world, sending data to Rust:");
// Bindings.send(new byte[]{ 1,2,3,4,5,6,7,8,9,10 }, 10);
// Console.WriteLine("Press a key to receive");
// Console.ReadKey(true);
// var data = await receiving;
// Console.WriteLine($"Received: {string.Join(',',data)}");