示例#1
0
        protected override void onRecv(byte[] data, int len)
        {
            _buffer.Append(data, 0, len);
            const int maxBufferSize = 0x10000000;

            if (_buffer.BufferSize > maxBufferSize)
            {
                _buffer.Delete(_buffer.Length);
            }

            int index = 0;

            while (index < _buffer.Length)
            {
                while (index + 8 <= _buffer.Length && (!isTaidMsgType(getUInt32(_buffer.Buffer, index)) || getUInt32(_buffer.Buffer, index + 4) >= 500))
                {
                    index++;
                }

                if (index + 8 <= _buffer.Length)
                {
                    int packetSize = 8 + (int)getUInt32(_buffer.Buffer, index + 4);
                    if (index + packetSize <= _buffer.Length)
                    {
                        parseCmd(_buffer.Buffer, index, packetSize);
                        index += packetSize;
                        continue;
                    }
                }
                break;
            }

            _buffer.Delete(index);
        }