예제 #1
0
 public OutMessageInfo(
     byte[] data,
     uint replyToMessageId,
     uint blockSize,
     IProgress <OutMessageProgressInfo> progress = null
     )
 {
     ReplyToMessageId = replyToMessageId;
     Data             = ReliableSamHelper.SplitData(data, (int)blockSize);
     BlockSize        = blockSize;
     BlockCount       = ReliableSamHelper.GetBlocksCount(
         (uint)data.Length,
         blockSize
         );
     BlockConfirmed = new bool[BlockCount];
     BlocksSent     = new bool[BlockCount];
     Status         = OutMessageStatus.Start;
     _progress      = progress;
 }
        public InMessageInfo(
            uint messageSize,
            uint blockSize,
            uint replyToMessageId,
            byte messageKind,
            byte[] messageHash
            )
        {
            MessageKind = messageKind;
            uint blockCount = ReliableSamHelper.GetBlocksCount(
                messageSize,
                blockSize
                );

            ReplyToMessageId       = replyToMessageId;
            BlockSize              = blockSize;
            BlockCount             = blockCount;
            Status                 = InMessageStatus.HandshakeReceived;
            BlocksReceived         = new bool[blockCount];
            ReceivedDataChunkSizes = new uint[blockCount];
            uint totalSize = messageSize;

            for (int i = 0; i < blockCount; i++)
            {
                if (totalSize >= blockSize)
                {
                    ReceivedDataChunkSizes[i] = blockSize;
                    totalSize -= blockSize;
                }
                else
                {
                    ReceivedDataChunkSizes[i] = totalSize;
                }
            }
            ReceivedData = Enumerable.Repeat <byte[]>(null, (int)blockCount).ToArray();
            MessageSize  = messageSize;
            MessageHash  = messageHash;
            EventFired   = false;
        }