Exemplo n.º 1
0
        /// <summary>
        /// 执行命令
        /// </summary>
        /// <returns></returns>
        private bool isDoCommandBig()
        {
#if !DOTNET2
            receiveAsyncEventArgs.SetBuffer(ReceiveBuffer.Buffer, ReceiveBuffer.StartIndex, receiveBufferSize);
#endif
            Buffer.BlockCopy(ReceiveBuffer.Buffer, ReceiveBuffer.StartIndex + receiveIndex, ReceiveBigBuffer.Buffer, ReceiveBigBuffer.StartIndex, receiveCount - receiveIndex);
            if (compressionDataSize == dataSize)
            {
                SubArray<byte> data = new SubArray<byte> { Array = ReceiveBigBuffer.Buffer, Start = ReceiveBigBuffer.StartIndex, Length = dataSize };
                doCommandMark(ref data);
                ReceiveBigBuffer.Free();
            }
            else
            {
                if (MarkData != 0) TcpServer.CommandBuffer.Mark(ReceiveBigBuffer.Buffer, MarkData, ReceiveBigBuffer.StartIndex, compressionDataSize);
                SubBuffer.PoolBufferFull buffer = new SubBuffer.PoolBufferFull { StartIndex = dataSize };
                try
                {
                    AutoCSer.IO.Compression.DeflateDeCompressor.Get(ReceiveBigBuffer.Buffer, ReceiveBigBuffer.StartIndex, compressionDataSize, ref buffer);
                }
                finally { ReceiveBigBuffer.Free(); }
                if (buffer.Buffer == null) return false;
                if (buffer.PoolBuffer.Pool == null) ++Server.ReceiveNewBufferCount;
                doCommand(ref buffer);
            }
            return true;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 执行命令
        /// </summary>
        private void doCommandBig()
        {
#if !DOTNET2
            receiveAsyncEventArgs.SetBuffer(ReceiveBuffer.Buffer, ReceiveBuffer.StartIndex, receiveBufferSize);
#endif
            Buffer.BlockCopy(ReceiveBuffer.Buffer, ReceiveBuffer.StartIndex + receiveIndex, ReceiveBigBuffer.Buffer, ReceiveBigBuffer.StartIndex, receiveCount - receiveIndex);
            SubArray<byte> data = new SubArray<byte> { Array = ReceiveBigBuffer.Buffer, Start = ReceiveBigBuffer.StartIndex, Length = compressionDataSize };
            doCommandMark(ref data);
            ReceiveBigBuffer.Free();
        }
Exemplo n.º 3
0
        /// <summary>
        /// 解压缩并执行命令
        /// </summary>
        /// <returns></returns>
        private bool doCompressionBigDataCommand()
        {
#if !DOTNET2
            receiveAsyncEventArgs.SetBuffer(ReceiveBuffer.Buffer, ReceiveBuffer.StartIndex, receiveBufferSize);
#endif
            Buffer.BlockCopy(ReceiveBuffer.Buffer, ReceiveBuffer.StartIndex + receiveIndex, ReceiveBigBuffer.Buffer, ReceiveBigBuffer.StartIndex, receiveCount - receiveIndex);
            SubBuffer.PoolBufferFull buffer = new SubBuffer.PoolBufferFull { StartIndex = dataSize };
            try
            {
                AutoCSer.IO.Compression.DeflateDeCompressor.Get(ReceiveBigBuffer.Buffer, ReceiveBigBuffer.StartIndex, compressionDataSize, ref buffer);
            }
            finally { ReceiveBigBuffer.Free(); }
            return doCompressionCommand(ref buffer);
        }
Exemplo n.º 4
0
 /// <summary>
 /// 回调命令数据
 /// </summary>
 /// <returns></returns>
 private bool isOnBigDataLoopFixed()
 {
     //#if !DOTNET2
     //            receiveAsyncEventArgs.SetBuffer(ReceiveBuffer.Buffer, ReceiveBuffer.StartIndex, receiveBufferSize);
     //#endif
     Buffer.BlockCopy(ReceiveBuffer.Buffer, ReceiveBuffer.StartIndex + receiveIndex, ReceiveBigBuffer.Buffer, ReceiveBigBuffer.StartIndex, receiveCount - receiveIndex);
     if (ReceiveMarkData != 0)
     {
         CommandBuffer.Mark(ReceiveBigBuffer.Buffer, ReceiveMarkData, ReceiveBigBuffer.StartIndex, compressionDataSize);
     }
     if (compressionDataSize == dataSize)
     {
         OnReceive(ref ReceiveBigBuffer);
     }
     else
     {
         SubBuffer.PoolBufferFull buffer = new SubBuffer.PoolBufferFull {
             StartIndex = dataSize
         };
         try
         {
             AutoCSer.IO.Compression.DeflateDeCompressor.Get(ReceiveBigBuffer.Buffer, ReceiveBigBuffer.StartIndex, compressionDataSize, ref buffer);
         }
         finally { ReceiveBigBuffer.Free(); }
         if (buffer.Buffer == null)
         {
             return(false);
         }
         if (buffer.PoolBuffer.Pool == null)
         {
             ++ClientCreator.CommandClient.ReceiveNewBufferCount;
         }
         OnReceive(ref buffer);
     }
     receiveIndex = receiveCount = 0;
     return(true);
 }