Exemplo n.º 1
0
        public Task ConsumeAsync(EventContext <StateChanged> context)
        {
            //await Task.Delay(4000);

            lock (_lockObject)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Write($"------------");
                Console.ResetColor();
            }

            var    info = context.GetTopicInfo <StateChangedTopicInfo>();
            string aaa  = context.GetTopicEntity("Territory");

            if (info == null)
            {
                Console.WriteLine($"{context.Message.Topic} State: {context.EventArg.Value}");
            }
            else
            {
                //Console.WriteLine($"{context.Message.Topic} State: {context.EventArg.Value}, Territory: {context.EventArg.Territory}, ClientId: {context.EventArg.ClientId}");
                Console.WriteLine($"{context.Message.Topic} State: {context.EventArg.Value}, Territory: {info.Territory}, ClientId: {info.ClientId}");
            }
            return(Task.CompletedTask);
        }