From 7c26f68c63739f548620969a479ab72f7a46bea8 Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Tue, 26 Nov 2024 01:23:03 +0900 Subject: [PATCH] Workaround for ReadAllAsync() --- src/Libplanet.Net/Transports/NetMQTransport.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Libplanet.Net/Transports/NetMQTransport.cs b/src/Libplanet.Net/Transports/NetMQTransport.cs index b32391320a..443bcf985f 100644 --- a/src/Libplanet.Net/Transports/NetMQTransport.cs +++ b/src/Libplanet.Net/Transports/NetMQTransport.cs @@ -662,10 +662,26 @@ await ProcessMessageHandler.InvokeAsync( channel.Writer.Complete(); } +#if NETCOREAPP3_0 || NETCOREAPP3_1 || NET await foreach ( var messageContent in channel.Reader.ReadAllAsync( _runtimeCancellationTokenSource.Token)) { +#else + while (true) + { + MessageContent messageContent; + try + { + messageContent = await channel.Reader.ReadAsync( + _runtimeCancellationTokenSource.Token); + } + catch (ChannelClosedException) + { + break; + } + +#endif await ReplyMessageAsync( messageContent, message.Identity ?? Array.Empty(),