예제 #1
0
        public NewEnvironCommand(InputByteArray InputArray, CommandCode CmdCode)
            : base(InputArray, CmdCode, TelnetSubject.NEW_ENVIRON)
        {
            this.SubOption  = null;
            this.OptionList = new List <OptionVariable>();
            this.EndFound   = false;

            // statement contains additional parameters.
            if (this.CmdCode == CommandCode.SB)
            {
                var b1 = InputArray.GetNextByte();
                this.RawBytes.Append(b1);
                this.SubOption = b1.ToTelnetOptionParm(); // IS, SEND, INFO

                // list of VARs and USERVARS follow until IAC SE.
                if ((this.SubOption.Value == TelnetOptionParm.SEND) ||
                    (this.SubOption.Value == TelnetOptionParm.IS))
                {
                    while (true)
                    {
                        var ov = OptionVariable.Construct(InputArray);
                        if (ov == null)
                        {
                            break;
                        }
                        this.OptionList.Add(ov);
                        this.RawBytes.Append(ov.ToBytes());
                    }

                    if (InputArray.PeekIacSe())
                    {
                        this.EndFound = true;
                        this.RawBytes.Append(InputArray.GetBytes(2));
                    }
                }

                // parse the closing IAC SE
                ParseClosingSE(InputArray);
            }
        }