Пример #1
0
        private bool checkComplete()
        {
            int totalSize = 0;

            foreach (DSMCCDownloadDataBlock block in blocks)
            {
                totalSize += block.DataSize;
            }

            if (totalSize != size)
            {
                return(false);
            }

            if (!Compressed)
            {
                createData();
            }
            else
            {
                string reply = deflate();
                if (reply != null)
                {
                    if (Logger.ProtocolLogger != null)
                    {
                        Logger.ProtocolLogger.Write("Zlib deflate failed: " + reply);
                    }
                    throw (new InvalidOperationException("Zlib deflate failed: " + reply));
                }
            }

            if (Utils.CompareBytes(data, BIOPMessage.BiopMagic, BIOPMessage.BiopMagic.Length))
            {
                biopMessages = new Collection <BIOPMessage>();

                int processedSize = 0;

                while (processedSize != originalSize)
                {
                    BIOPMessage biopMessage = new BIOPMessage();
                    biopMessage.Process(data, processedSize);
                    biopMessages.Add(biopMessage);

                    processedSize = biopMessage.Index;
                }
            }

            return(true);
        }
Пример #2
0
        private bool checkComplete()
        {
            int totalSize = 0;

            foreach (DSMCCDownloadDataBlock block in blocks)
                totalSize += block.DataSize;

            if (totalSize != size)
                return (false);

            if (!Compressed)
                createData();
            else
            {
                string reply = deflate();
                if (reply != null)
                {
                    if (Logger.ProtocolLogger != null)
                        Logger.ProtocolLogger.Write("Zlib deflate failed: " + reply);
                    throw (new InvalidOperationException("Zlib deflate failed: " + reply));
                }
            }

            if (Utils.CompareBytes(data, BIOPMessage.BiopMagic, BIOPMessage.BiopMagic.Length))
            {
                biopMessages = new Collection<BIOPMessage>();

                int processedSize = 0;

                while (processedSize != originalSize)
                {
                    BIOPMessage biopMessage = new BIOPMessage();
                    biopMessage.Process(data, processedSize);
                    biopMessages.Add(biopMessage);

                    processedSize = biopMessage.Index;
                }
            }

            return (true);
        }