84 lines
2.8 KiB
C#
84 lines
2.8 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace DTS.Common.Interface.Connection
|
|
{
|
|
public interface IConnection: IDisposable
|
|
{
|
|
Task<int> SendAsync(byte[] sendBuffer,
|
|
int bufferStartOffset,
|
|
int bufferSizeToSend);
|
|
/// <summary>
|
|
/// returns true if the unit is soft disconnected
|
|
/// soft disconnected means we've connected then voluntarily disconnected with the expectation of reconnecting
|
|
/// </summary>
|
|
bool IsSoftDisconnected{ get; }
|
|
/// <summary>
|
|
/// soft disconnects the unit (voluntarily disconnect with the intention of reconnecting later)
|
|
/// </summary>
|
|
void SoftDisconnect();
|
|
/// <summary>
|
|
/// reconnects a soft disconnected unit
|
|
/// </summary>
|
|
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);
|
|
|
|
///// <summary>
|
|
///// current upload rate in b/s
|
|
///// </summary>
|
|
///// <returns></returns>
|
|
//double GetCurrentUploadRate();
|
|
///// <summary>
|
|
///// current download rate in b/s
|
|
///// </summary>
|
|
///// <returns></returns>
|
|
//double GetCurrentDownloadRate();
|
|
}
|
|
}
|