Ejemplo n.º 1
0
        public override void OnData(Commands.Data command)
        {
            if (command.BlockNumber == m_nextBlockNumber)
            {
                // We received a new block of data
                Context.InputOutputStream.Write(command.Bytes, 0, command.Bytes.Length);
                SendAcknowledgement(command.BlockNumber);

                // Was that the last block of data?
                if (command.Bytes.Length < Context.BlockSize)
                {
                    Context.RaiseOnFinished();
                    Context.SetState(new Closed());
                }
                else
                {
                    m_lastBlockNumber = command.BlockNumber;
                    m_nextBlockNumber = Context.BlockCounterWrapping.CalculateNextBlockNumber(command.BlockNumber);
                    m_bytesReceived  += command.Bytes.Length;
                    Context.RaiseOnProgress(m_bytesReceived);
                }
            }
            else if (command.BlockNumber == m_lastBlockNumber)
            {
                // We received the previous block again. Re-sent the acknowledgement
                SendAcknowledgement(command.BlockNumber);
            }
        }
Ejemplo n.º 2
0
        public override void OnData(Commands.Data command)
        {
            Receiving nextState = new Receiving();

            Context.SetState(nextState);
            nextState.OnCommand(command, Context.GetConnection().RemoteEndpoint);
        }
        public override void OnData(Commands.Data command)
        {
            if (command.BlockNumber != 1)
            {
                return;
            }

            // The client confirmed the options, so let's start receiving
            ITransferState nextState = new Receiving();

            Context.SetState(nextState);
            nextState.OnCommand(command, Context.GetConnection().RemoteEndpoint);
        }
Ejemplo n.º 4
0
        private void SendNextPacket(ushort blockNumber)
        {
            if (Context.InputOutputStream == null)
            {
                return;
            }

            int packetLength = Context.InputOutputStream.Read(m_lastData, 0, m_lastData.Length);

            m_lastBlockNumber = blockNumber;

            if (packetLength != m_lastData.Length)
            {
                // This means we just sent the last packet
                m_lastPacketWasSent = true;
                Array.Resize(ref m_lastData, packetLength);
            }

            ITFtpCommand dataCommand = new Commands.Data(blockNumber, m_lastData);

            SendAndRepeat(dataCommand);
        }
 public virtual void OnData(Commands.Data command)
 {
     throw new NotImplementedException();
 }