示例#1
0
        private async Task ClientAsync()
        {
            var utf8 = new UTF8Encoding();

            using (var client = new SubscriberSocket())
            {
                client.Connect(_eddnClientSettings.ConnectionString);
                client.SubscribeToAnyTopic();
                while (true)
                {
                    try
                    {
                        (var bytes, _) = await client.ReceiveFrameBytesAsync();

                        var uncompressed = ZlibStream.UncompressBuffer(bytes);
                        var result       = utf8.GetString(uncompressed);
                        await _messageDistributor.DistributeAsync(result);

                        _logger.LogInformation(result);
                    }
                    catch (Exception ex)
                    {
                        _logger.LogError(ex, "Error reading message queue");
                    }
                }
            }
        }