public override void OnCommand(ITftpCommand command, System.Net.EndPoint endpoint) { if (command is OptionAcknowledgement) { TransferOptionSet acknowledged = new TransferOptionSet((command as OptionAcknowledgement).Options); Context.FinishOptionNegotiation(acknowledged); BeginSendingTo(endpoint); } else if (command is Acknowledgement && (command as Acknowledgement).BlockNumber == 0) { Context.FinishOptionNegotiation(TransferOptionSet.NewEmptySet()); BeginSendingTo(endpoint); } else if (command is Error) { //The server denied our request Error error = (Error)command; Context.SetState(new ReceivedError(error)); } else { base.OnCommand(command, endpoint); } }
public override void OnCommand(ITFtpCommand command, System.Net.EndPoint endpoint) { switch (command) { case OptionAcknowledgement optionAcknowledgement: { TransferOptionSet acknowledged = new TransferOptionSet(optionAcknowledgement.Options); Context.FinishOptionNegotiation(acknowledged); BeginSendingTo(endpoint); break; } case Acknowledgement acknowledgement when acknowledgement.BlockNumber == 0: Context.FinishOptionNegotiation(TransferOptionSet.NewEmptySet()); BeginSendingTo(endpoint); break; case Error error: // The server denied our request Context.SetState(new ReceivedError(error)); break; default: base.OnCommand(command, endpoint); break; } }
public override void OnCommand(ITFtpCommand command, EndPoint endpoint) { if (command is Commands.Data || command is OptionAcknowledgement) { // The server acknowledged our read request. // Fix out remote endpoint Context.GetConnection().RemoteEndpoint = endpoint; } switch (command) { case Commands.Data _: { if (Context.NegotiatedOptions == null) { Context.FinishOptionNegotiation(TransferOptionSet.NewEmptySet()); } // Switch to the receiving state... ITransferState nextState = new Receiving(); Context.SetState(nextState); // ...and let it handle the data packet nextState.OnCommand(command, endpoint); break; } case OptionAcknowledgement optionAcknowledgement: // Check which options were acknowledged Context.FinishOptionNegotiation(new TransferOptionSet(optionAcknowledgement.Options)); // the server acknowledged our options. Confirm the final options SendAndRepeat(new Acknowledgement(0)); break; case Error error: Context.SetState(new ReceivedError(error)); break; default: base.OnCommand(command, endpoint); break; } }
public override void OnCommand(ITftpCommand command, EndPoint endpoint) { if (command is Data || command is OptionAcknowledgement) { //The server acknowledged our read request. //Fix out remote endpoint Context.GetConnection().RemoteEndpoint = endpoint; } if (command is Data) { if (Context.NegotiatedOptions == null) { Context.FinishOptionNegotiation(TransferOptionSet.NewEmptySet()); } //Switch to the receiving state... ITransferState nextState = new Receiving(); Context.SetState(nextState); //...and let it handle the data packet nextState.OnCommand(command, endpoint); } else if (command is OptionAcknowledgement) { //Check which options were acknowledged Context.FinishOptionNegotiation(new TransferOptionSet((command as OptionAcknowledgement).Options)); //the server acknowledged our options. Confirm the final options SendAndRepeat(new Acknowledgement(0)); } else if (command is Error) { Context.SetState(new ReceivedError((Error)command)); } else { base.OnCommand(command, endpoint); } }
private void Parse(TransferOption option) { options = new TransferOptionSet(new TransferOption[] { option }); }