Exemplo n.º 1
0
        private void _Unpack(byte[] data)
        {
            if (_preBuffer == null)
            {
                _preBuffer = data;
            }
            else
            {
                _preBuffer = ByteTool.Concat(_preBuffer, data);
            }
            var head = ByteTool.Cut(_preBuffer, 0, 4);

            if (head == null)
            {
                return;
            }
            var size = System.BitConverter.ToInt32(head, 0);
            var body = ByteTool.Cut(_preBuffer, 4, size);

            if (body == null)
            {
                return;
            }
            _DealData(body);
            var more = ByteTool.Cut(_preBuffer, size, _preBuffer.Length);

            _preBuffer = null;
            if (more != null)
            {
                _Unpack(more);
            }
        }