AlarmCountBridge.cs 991 B

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