using Edge.Core.Domain.FccOrderInfo; using Edge.Core.Parser; using System; using System.Collections.Generic; using System.Linq; using System.Net.Sockets; using System.Text; using System.Threading.Tasks; namespace Edge.Core.Processor { public interface IDeviceHandler where TMessage : MessageBase { /// /// The communicator has NOT started yet at this stage. /// /// void Init(IContext context); /// /// will be called every time that a message incoming from communicator. /// /// Task Process(IContext context); /// /// The method will be called from user for a generic test purpose, should implemented this method /// to cover most real life time logic to give user a meaningful and confidence result for how this processor would work /// when run for real. /// The method was guranteed to be called after DeviceHandler.Init, and Communicator.Start /// /// /// throw exception to indicates the test failed, otherwise, return a Completed task. Task Test(params object[] parameters) { throw new NotImplementedException("暂不支持测试"); } /// /// 接收到 MQTT 数据 /// /// 数据 json void OnReceiveMqttMessage(string message) { } /// /// 发送二维码信息 /// void SendQRCodeAsync() { } ///// ///// 发送实付金额给油机 ///// ///// //void SendActuallyPaid(FccOrderInfo orderInfo) { } ///// ///// 设置tcp连接客户端,所连接的服务端端口 ///// //void SetTcpClient(TcpClient? client,int? serverPort) { } ///// ///// 当与客户端断开链接 ///// //void OnTcpDisconnect() { } } public abstract class TestableActivePollingDeviceHandler : IDeviceHandler where TMessage : MessageBase { private IContext context; public virtual void Init(IContext context) { this.context = context; } public virtual Task Process(IContext context) { throw new NotImplementedException(); } } }