using Edge.Core.Parser; using Edge.Core.Parser.BinaryParser.MessageEntity; using System; using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; namespace Edge.Core.Processor { public interface IOutgoing where TMessage : MessageBase { /// /// should fire this event when a new message is on writing /// event EventHandler> OnWriting; /// /// /// /// request to remote peer, which should trigger a response from remote peer. /// predict of response correlated to request, first is the request, 2nd is the pending for capture response /// when response catpured, or timed out, this callback will be called, first parameter is the request, 2nd is the captured response or null for timed out case /// time out, by ms void WriteAsync(TMessage request, Func responseCapture, Action callback, int timeout); /// /// Send an outgoing message to remote device and wait an incoming (responding) message. /// /// request to remote peer, which should trigger a response from remote peer. /// predict of response correlated to request, first is the request, 2nd is the pending for capture response /// time out, by ms /// a response from remote device Task WriteAsync(TMessage request, Func responseCapture, int timeout); void Write(TMessage message); /// /// /// /// /// void Write(TMessage message, object extraControlParameter); } public class OutgoingEventArg : EventArgs { public T Message { get; set; } public object ExtraControlParameter { get; set; } } //public class BinaryOutgoing : Outgoing where TMessage : MessageTemplateBase //{ // public BinaryOutgoing(ICommunicator communicator) : base(communicator) // { // } // public override void Write(TMessage message) // { // } //} }