using System; using System.Threading.Tasks; namespace DTS.Common.Interface.Connection { public interface IConnection: IDisposable { Task SendAsync(byte[] sendBuffer, int bufferStartOffset, int bufferSizeToSend); /// /// returns true if the unit is soft disconnected /// soft disconnected means we've connected then voluntarily disconnected with the expectation of reconnecting /// bool IsSoftDisconnected{ get; } /// /// soft disconnects the unit (voluntarily disconnect with the intention of reconnecting later) /// void SoftDisconnect(); /// /// reconnects a soft disconnected unit /// void SoftConnect(); System.Net.Sockets.SocketFlags Flags { get; set; } event EventHandler OnDisconnected; // indicates that the device has not received a timely response to keep-alive void KeepAliveErrorReceived(); string ConnectString { get; } bool Connected { get; } void Create(string connectString); void Create(string connectString, string hostIPAddress); string GetConnectionData(); IAsyncResult BeginConnect(AsyncCallback callback, object callbackObject); void EndConnect(IAsyncResult ar); IAsyncResult BeginDisconnect(bool reuseSocket, AsyncCallback callback, object state); void EndDisconnect(IAsyncResult asyncResult); IAsyncResult BeginAccept(AsyncCallback callback, object state); IConnection EndAccept(IAsyncResult asyncResult); void Bind(int port); void Listen(int backlog); IAsyncResult BeginSend(byte[] sendBuffer, int bufferStartOffset, int bufferSizeToSend, AsyncCallback callback, object callbackObject); int EndSend(IAsyncResult ar); IAsyncResult BeginReceive(byte[] receiveBuffer, int bufferStartOffset, int maxSizeToReceive, AsyncCallback callback, object callbackObject); int EndReceive(IAsyncResult ar); ///// ///// current upload rate in b/s ///// ///// //double GetCurrentUploadRate(); ///// ///// current download rate in b/s ///// ///// //double GetCurrentDownloadRate(); } }