FaultPopupBridge.cs 1021 B

123456789101112131415161718192021222324252627282930313233343536
  1. using NEIntelligentControl2.Models.Alarm;
  2. using NEIntelligentControl2.Service.WebSocket;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace NEIntelligentControl2.Models.Messages
  9. {
  10. internal class FaultPopupBridge : IMessage
  11. {
  12. public List<string> MessageTypes { get; set; } = new List<string> { "SubscribePopupAlarm".GetConfiguration() };
  13. public Action<List<FaultInfo>> Messaged { get; set; }
  14. public async Task OnMessage(object message)
  15. {
  16. try
  17. {
  18. await Task.Run(onmessage);
  19. }
  20. catch (Exception e)
  21. {
  22. Console.WriteLine($"风机信息WebSocket数据解析失败:{e.Message}");
  23. }
  24. void onmessage()
  25. {
  26. var ss = message as List<FaultInfo>;
  27. if (ss == null) return;
  28. Messaged?.Invoke(ss);
  29. }
  30. }
  31. }
  32. }