//建立连接 public static void Connect(EccManager adapter, IEccReceiptListener receiptListener) { //初始化EccSocket if (GetInstance().eccSocket != null && GetInstance().eccSocket.Socket.Connected) { return; } //保存Ecc适配器对象,并为其设置ECCIoT实例 GetInstance().eccManager = adapter; adapter.EcciotInstance = GetInstance(); //实例化Ecc通信对象 GetInstance().eccSocket = new EccSocket(GetInstance().eccManager) { //设置字符编码 Encoding = Encoding }; //连接服务器 GetInstance().eccSocket.Connect(ipep, receiptListener); }
/// <summary> /// 连接服务器 /// </summary> /// <param name="manager"></param> /// <param name="successful"></param> /// <param name="failure"></param> public static void Connect(EccManager manager, AsyncCallback successful, AsyncCallback failure) { //初始化EccSocket if (GetInstance().eccSocket != null && GetInstance().eccSocket.Socket.Connected) { return; } //保存Ecc适配器对象,并为其设置ECCIoT实例 GetInstance().eccManager = manager; manager.EcciotInstance = GetInstance(); //实例化Ecc通信对象 GetInstance().eccSocket = new EccSocket(GetInstance().eccManager) { //设置字符编码 Encoding = Encoding }; //连接服务器 GetInstance().eccSocket.Connect(ipep, successful, failure); }
public EccSocket(EccManager adapter) { EccReceiptListener = adapter; EccDataReceiveListener = adapter; EccExceptionListener = adapter; }