/// <summary>Process the specified input.</summary>
        /// <param name="data">The data to be processed.</param>
        public override void ProcessInput(byte data)
        {
            switch (data)
            {
                case IAC:
                    // If we have another IAC then we put it into the buffer.
                    Parent.SubRequestBuffer.Add(data);
                    Parent.ChangeState(new ConnectionTelnetStateSubRequest(Parent));
                    break;
                case SE:
                    // This signifies the end of the sub negotiation string, so we need to process it.
                    // The first item in the buffer should be our option code.
                    int optionCode = Parent.SubRequestBuffer[0];

                    // Remove the option code from the buffer.
                    Parent.SubRequestBuffer.RemoveAt(0);

                    // Find the related option.
                    TelnetOption option = (TelnetOption)Parent.TelnetOptions.Find(delegate(ITelnetOption o) { return o.OptionCode == optionCode; });
                    if (option == null)
                    {
                        // We have received an option code that we dont recognise, so we create a temporary
                        // telnet option to deal with it.
                        option = new TelnetOption("temp", optionCode, false, Parent.Connection);
                    }

                    // Perform the sub negotiation.
                    option.ProcessSubNegotiation(Parent.SubRequestBuffer.ToArray());
                    Parent.SubRequestBuffer.Clear();

                    // Set our state back to normal.
                    Parent.ChangeState(new ConnectionTelnetStateText(Parent));
                    break;
            }
        }
Beispiel #2
0
        /// <summary>Process the specified input.</summary>
        /// <param name="data">The data to be processed.</param>
        public override void ProcessInput(byte data)
        {
            // If the data is not one of our implemented options then we reset back.
            TelnetOption option = (TelnetOption)Parent.TelnetOptions.Find(delegate(ITelnetOption o) { return(o.OptionCode == data); });

            if (option == null)
            {
                // We have received an option code that we dont recognise, so we create a temporary
                // telnet option to deal with it.
                option = new TelnetOption("temp", data, false, Parent.Connection);
            }

            switch (this.optionCode)
            {
            case (int)TelnetResponseCode.DO:
                option.NegotiateDo();
                break;

            case (int)TelnetResponseCode.DONT:
                option.NegotiateDont();
                break;

            case (int)TelnetResponseCode.WILL:
                option.NegotiateWill();
                break;

            case (int)TelnetResponseCode.WONT:
                option.NegotiateWont();
                break;
            }

            Parent.ChangeState(new ConnectionTelnetStateText(Parent));
        }
        /// <summary>Process the specified input.</summary>
        /// <param name="data">The data to be processed.</param>
        public override void ProcessInput(byte data)
        {
            // If the data is not one of our implemented options then we reset back.
            TelnetOption option = (TelnetOption)Parent.TelnetOptions.Find(delegate(ITelnetOption o) { return o.OptionCode == data; });
            if (option == null)
            {
                // We have received an option code that we dont recognise, so we create a temporary
                // telnet option to deal with it.
                option = new TelnetOption("temp", data, false, Parent.Connection);
            }

            switch (this.optionCode)
            {
                case (int)TelnetResponseCode.DO:
                    option.NegotiateDo();
                    break;
                case (int)TelnetResponseCode.DONT:
                    option.NegotiateDont();
                    break;
                case (int)TelnetResponseCode.WILL:
                    option.NegotiateWill();
                    break;
                case (int)TelnetResponseCode.WONT:
                    option.NegotiateWont();
                    break;
            }

            Parent.ChangeState(new ConnectionTelnetStateText(Parent));
        }
Beispiel #4
0
        /// <summary>Process the specified input.</summary>
        /// <param name="data">The data to be processed.</param>
        public override void ProcessInput(byte data)
        {
            switch (data)
            {
            case IAC:
                // If we have another IAC then we put it into the buffer.
                Parent.SubRequestBuffer.Add(data);
                Parent.ChangeState(new ConnectionTelnetStateSubRequest(Parent));
                break;

            case SE:
                // This signifies the end of the sub negotiation string, so we need to process it.
                // The first item in the buffer should be our option code.
                int optionCode = Parent.SubRequestBuffer[0];

                // Remove the option code from the buffer.
                Parent.SubRequestBuffer.RemoveAt(0);

                // Find the related option.
                TelnetOption option = (TelnetOption)Parent.FindOption(optionCode);
                if (option == null)
                {
                    // We have received an option code that we dont recognise, so we create a temporary
                    // telnet option to deal with it.
                    option = new TelnetOption("temp", optionCode, false, Parent.Connection);
                }

                // Perform the sub negotiation.
                option.ProcessSubNegotiation(Parent.SubRequestBuffer.ToArray());
                Parent.SubRequestBuffer.Clear();

                // Set our state back to normal.
                Parent.ChangeState(new ConnectionTelnetStateText(Parent));
                break;
            }
        }