Esempio 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);
        }
Esempio n. 2
0
 public Task ConsumeAsync(EventContext <StatusChanged> context)
 {
     try
     {
         var topicInfo = context.GetTopicInfo <StatusChangedTopicInfo>();
         Console.WriteLine($"{context.Message.Topic} Status: {context.EventArg.Value}, Territory: {topicInfo.Territory}, Server: {topicInfo.Server}");
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     return(Task.CompletedTask);
 }