using System;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using Team.Communicate.Data;
using Team.Communicate.EventArg;
namespace Team.Communicate.Interfaces
{
public interface IAsyncTcpClient : IDisposable
{
bool IsAutoConnect { get; set; }
Encoding Encoding { get; set; }
IPAddress RemoteIpAddress { get; set; }
int Port { get; }
bool IsConnected { get; }
///
/// 连接成功为true
///
/// 1.exception ArgumentOutOfRangeException
/// 2.exception ArgumentNullException
///
bool Connect();
///
/// 异步连接成功为true
///
/// 1.exception ArgumentOutOfRangeException
/// 2.exception ArgumentNullException
///
Task ConnectAsync();
///
/// 异步发送
///1.Exception 未连接异常
///
///
TransmissionResult SendString(string msg);
///
/// 异步发送
///1.Exception 未连接异常
///
///
Task SendStringAsync(string msg);
///
/// 发送并接收一个消息
///
///
///
string SendAndReceiveString(string msg);
///
/// 异步发送并接收一个消息
///
///
///
Task SendAndReceiveStringAsync(string msg);
///
/// 设定RemoteIp和端口,如果已经连接并且端口和Ip发送变化将断开连接
///
/// ip地址
/// 端口
///
///
void SetRemoteIpOrPort(string ip, int port);
///
/// 异步发送
///
///
///
TransmissionResult SendBytes(byte[] data);
///
/// 异步发送
///
///
///
Task SendBytesAsync(byte[] data);
///
/// 异步接收
///
///
Task ReceiveStringAsync();
///
/// 异步接收
///
///
string ReceiveString();
///
/// 异步接收字节
///
///
Task ReceiveBytesAsync();
///
/// 接收字节
///
///
byte[] ReceiveBytes();
void DisConnect();
///
/// tcp状态改变事件
///
event EventHandler StatusChanged;
///
/// tcp获取数据事件
///
event EventHandler Received;
event EventHandler Sent;
void Reconnect();
bool Connecting { get; }
}
}