using Muchinfo.TASClient.NetworkCore; using System; namespace Muchinfo.TASClient.Service.LinkProxy.TCP { /// /// 业务代理连接 /// public class TradeTcpLinkProxy { private string _host; ////主机地址 private int _port; ////通信端口号 private TCPManager _tcpManager; /// /// 创建业务连接 /// public TradeTcpLinkProxy(string host, int port) { _host = host; _port = port; _tcpManager = new TCPManager(new TradeTcpCallback()); _tcpManager.Connect(_host, _port, ConnectSuccess, ConnectFail); } /// /// 连接失败 /// /// 错误码 /// 连接描述 private void ConnectFail(int errorCode, string desc) { //todo:通知连接失败 } /// /// 连接成功 /// private void ConnectSuccess() { //todo:通知连接成功 } /// /// 发送消息, /// /// 消息内容 /// 成功回复 /// 错误回复 public void SendPackage(TCPPackage package, Action successAction, Action failAction) { if (_tcpManager == null) { //todo:抛异常 return; } _tcpManager.SendMessage(package, successAction, failAction); } } }