예제 #1
0
 private void SendTask()
 {
     while (client != null && client.Connected)
     {
         BinaryObj binObj = null;
         try
         {
             if (sendQueue.TryDequeue(out binObj))
             {
                 stream.Write(binObj.bytes, 0, binObj.length);
                 rps++;
                 //stream.Flush();
             }
         }
         catch (OperationCanceledException) { }
         catch (Exception e)
         {
             LogError?.Invoke(e.ToString());
         }
         finally
         {
             if (binObj != null)
             {
                 binObj.ResetOjb();
                 BinaryObjPool.Checkin(binObj);
             }
         }
     }
     LogInfo?.Invoke("SimpleTcpClient SendTask shutdown");
 }
예제 #2
0
 private void SendTask()
 {
     while (socket != null && socket.Connected)
     {
         BinaryObj binObj = null;
         try
         {
             if (sendQueue.TryDequeue(out binObj))
             {
                 socket.Send(binObj.bytes, 0, binObj.length, SocketFlags.None);
             }
         }
         catch (OperationCanceledException) { }
         catch (Exception e)
         {
             LogError?.Invoke(e.ToString());
         }
         finally
         {
             if (binObj != null)
             {
                 binObj.ResetOjb();
                 BinaryObjPool.Checkin(binObj);
             }
         }
     }
     LogInfo?.Invoke("SimpleTcpClient SendTask shutdown");
 }
예제 #3
0
 public static void Checkin(BinaryObj binObj)
 {
     binObj.ResetOjb();
     if (binObj.type == BinaryObj.PresetType.RequestToMatching)
     {
         PoolForReq.Pool.Checkin(binObj);
     }
     else if (binObj.type == BinaryObj.PresetType.ProcessOrderResult)
     {
         PoolForResp.Pool.Checkin(binObj);
     }
     else if (binObj.type == BinaryObj.PresetType.Transaction)
     {
         PoolForTx.Pool.Checkin(binObj);
     }
 }