ShellChinaEPSClientHandler.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Threading.Tasks;
  5. using Edge.Core.Processor;using Edge.Core.IndustryStandardInterface.Pump;
  6. using ShellChina_EPS_Project_CarPlatePay_EpsClient_App.MessageEntity.Base;
  7. namespace ShellChina_EPS_Project_CarPlatePay_EpsClient_App
  8. {
  9. public class ShellChinaEPSClientHandler : IDeviceHandler<byte[], MessageBase>
  10. {
  11. public IContext<byte[], MessageBase> EPSClientContext { get; set; }
  12. private object syncObj = new object();
  13. public void Init(IContext<byte[], MessageBase> context)
  14. {
  15. EPSClientContext = context;
  16. }
  17. /// <summary>
  18. /// called when message received from EPS
  19. /// </summary>
  20. /// <param name="context"></param>
  21. public Task Process(IContext<byte[], MessageBase> context)
  22. {
  23. //Message received from EPS
  24. return Task.CompletedTask;
  25. }
  26. //MessageBase will replace with the 8583 message type
  27. public void WriteAsync(MessageBase request, Func<MessageBase, MessageBase, bool> responseCapture, Action<MessageBase, MessageBase> callback, int timeout)
  28. {
  29. lock (syncObj)
  30. {
  31. this.EPSClientContext.Outgoing.WriteAsync(request, responseCapture,callback,timeout);
  32. }
  33. }
  34. }
  35. }