Esempio n. 1
0
 /// <summary>
 /// 发送数据到指定终端(无回调函数)
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="txdata"></param>
 public void Send(ClientObject obj, TxData txdata)
 {
     Send(obj, txdata, null);
 }
Esempio n. 2
0
 void Receive(ClientFather obj)
 {
     try
     {
         obj.ConnSocket.workSocket.BeginReceive(obj.ConnSocket.buffer, 0, obj.ConnSocket.buffer.Length, SocketFlags.None, p =>
         {
             //接收处理逻辑
             string msg = ReceiveCallback(p, obj.ConnSocket);
             if (msg != null)
             {
                 var txdata = new TxData(msg);
                 if (ReceiveDataEvent != null)
                 {
                     ReceiveDataEvent.BeginInvoke(obj, txdata, null, null);
                 }
             }
             Receive(obj);
         }, obj);
     }
     catch (Exception ex)
     {
         SocketError(obj, ex.Message);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// 发送数据到指定终端
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="txdata"></param>
 /// <param name="sendCallback">发送后的回调函数</param>
 public void Send(ClientFather client, TxData txdata, AsyncCallback sendCallback)
 {
     lock (obj.sendLockObj)
     {
         SendClientObject sendObj = new SendClientObject
         {
             ID = Guid.NewGuid().ToString(),
             client = client,
             txData = txdata
         };
         Send(sendObj, sendCallback);
     }
 }