From 5ece345a3ff1794a1bb2bf17680d960c1918a032 Mon Sep 17 00:00:00 2001 From: Mikhail Mitrofanow Date: Wed, 6 Aug 2025 14:50:10 +0300 Subject: [PATCH 1/2] Add logging --- mROA/Implementation/ChannelInteractionModule.cs | 7 +++++++ mROA/mROA.csproj | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/mROA/Implementation/ChannelInteractionModule.cs b/mROA/Implementation/ChannelInteractionModule.cs index 6b41ec0..7393597 100644 --- a/mROA/Implementation/ChannelInteractionModule.cs +++ b/mROA/Implementation/ChannelInteractionModule.cs @@ -170,6 +170,9 @@ namespace mROA.Implementation } var message = meta.ToMessage(_buffer.Span); +#if TRACE + Console.WriteLine("RECV " + message); +#endif MessageReceived(message); } @@ -183,11 +186,15 @@ namespace mROA.Implementation private async Task Send(NetworkMessage message, CancellationToken token = default) { + Thread.SpinWait(10000); var meta = message.ToMeta(); MemoryMarshal.Write(_buffer.Span, ref meta); message.Data.CopyTo(_buffer.Span[19..]); var sendingSpan = _buffer[..(19 + meta.BodyLength)]; await _ioStream.WriteAsync(sendingSpan, token); + #if TRACE + Console.WriteLine("SEND " + message); + #endif // _logger.LogTrace("SEND {0}", message.ToString()); } diff --git a/mROA/mROA.csproj b/mROA/mROA.csproj index 6e47d56..fb21e70 100644 --- a/mROA/mROA.csproj +++ b/mROA/mROA.csproj @@ -22,7 +22,7 @@ - + TRACE; From 37e768d6e8b5c46d441303b8ecff6e7fc139ff35 Mon Sep 17 00:00:00 2001 From: Mikhail Mitrofanow Date: Wed, 6 Aug 2025 15:03:46 +0300 Subject: [PATCH 2/2] Remove waiting from demo --- Example.Frontend/Program.cs | 5 ----- mROA/Implementation/ChannelInteractionModule.cs | 1 - mROA/mROA.csproj | 2 +- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/Example.Frontend/Program.cs b/Example.Frontend/Program.cs index de23bb0..7a6ce5a 100644 --- a/Example.Frontend/Program.cs +++ b/Example.Frontend/Program.cs @@ -86,14 +86,12 @@ class Program DemoCheck.EventCallback = true; }; Console.WriteLine("Printer created"); - Thread.Sleep(100); frontendBridge.Obstacle(); var name = disposingPrinter.GetName(); DemoCheck.BasicNonParamsCall = true; Console.WriteLine("Printer name : {0}", name); - Thread.Sleep(100); disposingPrinter.SomeoneIsApproaching("Mikhail"); Console.WriteLine("Approaching detected"); @@ -102,17 +100,14 @@ class Program factory.Register(disposingPrinter); DemoCheck.ClientBasedImplementation = true; Console.WriteLine("Registered printer"); - Thread.Sleep(100); var registered = factory.GetFirstPrinter(); Console.WriteLine("First printer"); - Thread.Sleep(100); Console.WriteLine(registered); Console.WriteLine("Collecting all printers"); var names = factory.CollectAllNames(); - Thread.Sleep(100); Console.WriteLine("Names: " + string.Join(", ", names)); diff --git a/mROA/Implementation/ChannelInteractionModule.cs b/mROA/Implementation/ChannelInteractionModule.cs index 7393597..1f90654 100644 --- a/mROA/Implementation/ChannelInteractionModule.cs +++ b/mROA/Implementation/ChannelInteractionModule.cs @@ -186,7 +186,6 @@ namespace mROA.Implementation private async Task Send(NetworkMessage message, CancellationToken token = default) { - Thread.SpinWait(10000); var meta = message.ToMeta(); MemoryMarshal.Write(_buffer.Span, ref meta); message.Data.CopyTo(_buffer.Span[19..]); diff --git a/mROA/mROA.csproj b/mROA/mROA.csproj index fb21e70..aded77c 100644 --- a/mROA/mROA.csproj +++ b/mROA/mROA.csproj @@ -22,7 +22,7 @@ - TRACE; + ;