25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

69 lines
1.9 KiB

  1. using JT808.Gateway.Abstractions;
  2. using JT808.Gateway.Abstractions.Configurations;
  3. using JT808.Gateway.MsgLogging;
  4. using JT808.Gateway.Transmit;
  5. using JT808.Protocol;
  6. using Microsoft.Extensions.Logging;
  7. using Microsoft.Extensions.Options;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Text;
  11. namespace JT808.Gateway.QueueHosting.Impl
  12. {
  13. public class JT808CustomMessageHandlerImpl : JT808MessageHandler
  14. {
  15. private readonly ILogger logger;
  16. public JT808CustomMessageHandlerImpl(
  17. ILoggerFactory loggerFactory,
  18. IJT808Config jT808Config) : base(
  19. jT808Config)
  20. {
  21. logger = loggerFactory.CreateLogger<JT808CustomMessageHandlerImpl>();
  22. //添加自定义消息
  23. HandlerDict.Add(0x9999, Msg0x9999);
  24. }
  25. /// <summary>
  26. /// 重写消息处理器
  27. /// </summary>
  28. /// <param name="request"></param>
  29. /// <param name="session"></param>
  30. public override byte[] Processor(in JT808HeaderPackage request)
  31. {
  32. try
  33. {
  34. var down = base.Processor(request);
  35. return down;
  36. }
  37. catch (Exception)
  38. {
  39. return default;
  40. }
  41. }
  42. /// <summary>
  43. /// 重写自带的消息
  44. /// </summary>
  45. /// <param name="request"></param>
  46. public override byte[] Msg0x0200(JT808HeaderPackage request)
  47. {
  48. //logger.LogDebug("由于过滤了0x0200,网关是不会处理0x0200消息的应答");
  49. var data = base.Msg0x0200(request);
  50. return data;
  51. }
  52. /// <summary>
  53. /// 自定义消息
  54. /// </summary>
  55. /// <param name="request"></param>
  56. /// <returns></returns>
  57. public byte[] Msg0x9999(JT808HeaderPackage request)
  58. {
  59. logger.LogDebug("自定义消息");
  60. return default;
  61. }
  62. }
  63. }