Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 

45 lignes
1.4 KiB

  1. using JT808.Gateway.MsgIdHandler;
  2. using JT808.Gateway.SimpleQueueNotification.Hubs;
  3. using JT808.Protocol.Extensions;
  4. using Microsoft.AspNetCore.SignalR;
  5. using Microsoft.Extensions.Logging;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text.Json;
  10. using System.Threading.Tasks;
  11. namespace JT808.Gateway.SimpleQueueNotification.Impl
  12. {
  13. public class JT808MsgIdHandlerImpl : IJT808MsgIdHandler
  14. {
  15. private readonly ILogger<JT808MsgIdHandlerImpl> logger;
  16. private readonly IHubContext<JT808MsgHub> _hubContext;
  17. public JT808MsgIdHandlerImpl(
  18. ILoggerFactory loggerFactory,
  19. IHubContext<JT808MsgHub> hubContext
  20. )
  21. {
  22. this._hubContext = hubContext;
  23. logger = loggerFactory.CreateLogger<JT808MsgIdHandlerImpl>();
  24. }
  25. public void Processor((string TerminalNo, byte[] Data) parameter)
  26. {
  27. try
  28. {
  29. if (logger.IsEnabled(LogLevel.Trace))
  30. {
  31. logger.LogTrace($"{parameter.TerminalNo}-{parameter.Data.ToHexString()}");
  32. }
  33. _hubContext.Clients.All.SendAsync("ReceiveMessage", parameter.TerminalNo, parameter.Data.ToHexString());
  34. }
  35. catch (Exception ex)
  36. {
  37. logger.LogError(ex, "");
  38. }
  39. }
  40. }
  41. }